The 'RegisterAssembly' function failed.

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

Only registered users are allowed to subscribe.
The 'RegisterAssembly' function failed.
I reference the encrypted library 'Dots-InmengTools.dll' in my project 
Subscribe
Garfield Huang




Posts: 8
Joined: 2019-06-03
[CODE]<LogEntry Date="2019-06-13 08:55:30" Severity="Exception" Source="AddinExpress.Projects.Common.Registrator.dteBuildEvents_OnBuildProjConfigDone" ProcessId="5048">
<Exception Type="System.Exception" Source="AddinExpress.Projects.Common.Registrator.dteBuildEvents_OnBuildProjConfigDone">
<Message>The 'RegisterAssembly' function failed.</Message>
<Exception Type="System.Reflection.TargetInvocationException" Source="mscorlib">
<Message>An exception has occurred in the target of the call</Message>
<Exception Type="System.TypeInitializationException" Source="YinMeng.PrintAdapter">
<Message>“<Module>”Type initializer throws an exception.</Message>
<Exception Type="System.Exception" Source="Dots-InmengTools">
<Message>-=Load DNGuard Runtime library failed, runtime library not found or Access Denied.=-</Message>
<StackTrace> 在 ZYXDNGuarder.Startup()
在 .cctor()</StackTrace>
</Exception>
</Exception>
</Exception>
</Exception>
</LogEntry>

how to fix this issue. thank you.
Posted 12 Jun, 2019 20:53:10 Top
Andrei Smolin


Add-in Express team


Posts: 16477
Joined: 2006-05-11
Hello Garfield,

The error message explains that there was an issue when creating (initializing) a type defined in that assembly. A possible causes are: that assembly isn't found (do you reference it? Is that reference broken? Does this assembly exists? Is it of the correct version?) or access was denied.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jun, 2019 01:49:34 Top
Garfield Huang




Posts: 8
Joined: 2019-06-03
Thank you for your timely reply. I'm very sure that assembly exists on correct folder, and reference it with right way. But if i reference the assembly without encrypted that there wasn't an issue.
Posted 13 Jun, 2019 02:23:49 Top
Andrei Smolin


Add-in Express team


Posts: 16477
Joined: 2006-05-11
Garfield Huang writes:
without encrypted


Sorry? Anyway, this is something that prevents the .NET Framework from finding out your assembly.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jun, 2019 03:54:33 Top
Garfield Huang




Posts: 8
Joined: 2019-06-03
however, use the same encrypted assembly in other project that works fine. i don't known why. could you analyse my demo without add-in express? tks
Posted 13 Jun, 2019 04:15:59 Top
Andrei Smolin


Add-in Express team


Posts: 16477
Joined: 2006-05-11
Hello Garfield,

Can it be that the encrypted assembly relies on a license file which is missing in the output folder of your add-in project? If not, in your other project (I assume it isn't an Add-in Express project) set the Register for COM Interop check box (see the Build tab of your project properties) and build the project; I wonder if it builds with no issues in this case.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jun, 2019 06:13:13 Top
Garfield Huang




Posts: 8
Joined: 2019-06-03
yes. it builds with no issues in this case. Oh my god... could you give your email to me? i will send my project without add-in express to you. please help me to check the code. thank you very much!
Posted 13 Jun, 2019 07:06:30 Top
Andrei Smolin


Add-in Express team


Posts: 16477
Joined: 2006-05-11
Hello Garfield,

Thank you.

Find the support email address in {Add-in Express installation folder}\readme.txt; please make sure your email contains a link to this topic.

You can send us your Add-in Express project demonstrating the issue. We won't accept a non-Add-in Express project.

I suppose that "encrypting" above is in fact "obfuscating". If so, don't obfuscate the public things that the add-in module provides as these are required for the add-in module to be a COM add-in.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jun, 2019 07:45:28 Top
Andrei Smolin


Add-in Express team


Posts: 16477
Joined: 2006-05-11
Hello Garfield,

The issue is this declaration:

private MyLibrary.MyClass dcpt = new MyLibrary.MyClass();


Replace it with this one:

private MyLibrary.MyClass dcpt;


You need initialize all class-level variables in an event of the add-in module. This also applies to calling custom things from the module's constructor: move them to an event. Depending on the host application, its version, the way you start it, the very first event fired on the add-in module is either AddinInitialize or OnRibbonBeforeCreate. Also, you can use the OnHostApplicationInitialized method which you can override and which is called even before these events.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Jun, 2019 01:58:39 Top
Garfield Huang




Posts: 8
Joined: 2019-06-03
Thank you verrrrrrrrrrrrrrrrrrrrrrrrrrrrry much.
Posted 14 Jun, 2019 04:47:16 Top