Reputation: 731
I have created an add-in for SolidWorks in C# using <TargetFramework>netcoreapp3.1</TargetFramework>
. Building (with dotnet build
) produces a MyAddin.dll
as well as a MyAddin.comhost.dll
.
In order to register the add-in, I can run (with admin permissions):
regsvr32 MyAddin.comhost.dll
This makes the add-in usable in SolidWorks.
However, if I share the build output files with my coworker and he tries to register the .dll in the same way, a messagebox appears that says:
The module "MyAddin.comhost.dll" was loaded but the call to DllRegisterServer failed with error code 0x80040111.
For more information about this problem, search online using the error code as a search term.
When he builds the project on his machine and shares it with me, I get the same error.
We both run regsvr32
with admin permissions.
The main contents of my project's .csproj
file is:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>9.0</LangVersion>
<EnableComHosting>true</EnableComHosting>
<XCadRegDll>false</XCadRegDll>
<UseWindowsForms>true</UseWindowsForms>
<DebugType>portable</DebugType>
<nullable>enable</nullable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<NoWarn>NU1701,CS8002</NoWarn>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
...
</Project>
Again, either of us can register the .dll just fine if we build it on our own machines. It is only when we try to register the .dll built by the other that we get the error. It is important that we can register on other machines because we need to be able to make the add-in available to other people at our company who cannot build it themselves.
Is there some requirement for .dll's passed to regsvr32
that is not fulfilled when we use files built on another machine? Is there a different way do this? Thanks.
Upvotes: 1
Views: 980
Reputation: 31
This error appears if you only copy MyAddin.comhost.dll
and not MyAddin.dll
. It actually means that MyAddin.dll
(where the [ComVisible]
Classes reside) is missing.
Upvotes: 1