Cannot Register Assembly

Add-in Express™ Support Service
That's what is more important than anything else

Cannot Register Assembly
Error occurs during rebuild, but works on other machines. 
Androulla Pavlou




Posts: 21
Joined: 2016-05-25
I'm getting this error upon Rebuild:
Cannot register assembly "F:\Visual Studio 2015\Projects\123CAD Versions\To Client\170526 CAD123 TPJ\170526 CAD123\123CAD\bin\Debug\CAD123.dll". Exception has been thrown by the target of an invocation. CAD123

Visual Studio 2015 Professional
Same error in VS 2012 Professional
Windows 10 Professional.

Same project copied to another machine compiles just fine:
Visual Studio 2015 Professional
windows 10 Professional

I have been working on this project in Visual Studio since January 2017. My colleague and I work on it in two separate locations and we pass the entire project back and forth at various times in the day.

The version of which I am speaking also registers/compiles just fine for him. Not sure of OS, but he has Visual Studio 2017. This *should* not make any difference because, again, it works fine on my other machine.

I have tried Clean, Build, Rebuild in every conceivable order after exiting Visual Studio, rebooting the machine, changing .NET versions, etc. All to no avail.

Note that the problem began occurring at least two weeks ago with other, earlier, daily versions of the project. However, on those occasions, after enough tinkering (Build, Clean, Rebuild, Exit, Re-load and/or reboot machine) it always finally worked eventually.

Note that I have also unregistered and removed from the registry. However, now I cannot re-register.

I have completely uninstalled Visual Studio 2015 and re-installed. Same result.

it seems clear to me that it's something to do with my machine and possible something to do with the project as well (the same project from 2 months ago appears to compile fine).

Something has changed and I don't know what and I don't know where to go next.

Thanks.

tim Jeffryes
Posted 26 May, 2017 23:58:43 Top
Andrei Smolin


Add-in Express team


Posts: 18791
Joined: 2006-05-11
Hello Tim,

Androulla Pavlou writes:
This *should* not make any difference because, again, it works fine on my other machine.


Most probably, you have some difference in your environment. Do you have custom code in the constructor of the add-in module? If so, move it to an event of the module. The best candidates are OnRibbonBeforeCreate and AddinInititalize: one of them is the very first event that the add-in module receives after Office loads your add-in. Note that OnRibbonBeforeCreate may occur several times in an Outlook add-in.

Also, if you initialize any complex-type variable declared on the class level of the add-in module, move initialization to the same event (see above).


Andrei Smolin
Add-in Express Team Leader
Posted 29 May, 2017 05:03:01 Top
Androulla Pavlou




Posts: 21
Joined: 2016-05-25
thanks for your reply.

Sorry, but when you say "constructor" of the add-in module, do you mean

AddInModule.New()

?

thanks.

BTW, I found the error using RegAsm. The offending line(s) appear to be something like this

wsMyWorksheet = New Excel.Worksheet

As you know, this syntax really isn't valid in VBA and I'm not sure why my colleague wrote it. Remarking this line solved the problem. But how is this related to what you have stated here?
Posted 02 Jun, 2017 22:33:23 Top
Andrei Smolin


Add-in Express team


Posts: 18791
Joined: 2006-05-11
Hello Androulla,

Androulla Pavlou writes:
Sorry, but when you say "constructor" of the add-in module, do you mean


I mean
Partial Public Class AddinModule

    <System.Diagnostics.DebuggerNonUserCode()> _
    Public Sub New()
        MyBase.New()

        Application.EnableVisualStyles()

        'This call is required by the Component Designer
        InitializeComponent()

        'Please add any initialization code to the AddinInitialize event handler

    End Sub


My question was: do you modify this method? If yes, please check the suggestions from my previous post.

Androulla Pavlou writes:
But how is this related to what you have stated here?


This code line might cause the issue if it is located in the constructor of the add-in module.


Andrei Smolin
Add-in Express Team Leader
Posted 05 Jun, 2017 03:22:13 Top