1

I trying to get a .NET DLL to be exposed as a COM class, too, and be accessible from non-.NET languages like VBA, C++ or Delphi.

I created my C# DLL just fine, and I was able to register it on my test server as a COM component:

C:\Windows\Microsoft.NET\Framework\v4.0.30319>regasm c:\inst\MyComComponent.dll /codebase
Microsoft (R) .NET Framework Assembly Registration Utility 4.0.30319.1
Copyright (C) Microsoft Corporation 1998-2004. All rights reserved.

RegAsm : warning RA0000 : Registering an unsigned assembly with /codebase can cause your assembly to interfere with other applications that may be installed on the same computer. The /codebase switch is intended to be used only with signed assemblies. Please give your assembly a strong name and re-register it.

Types registered successfully

OK, it worked - but it throws that ugly warning, so I went and created a *.snk file for my class library

sn -k MyComComponent.snk

and I added this *.snk file to my project properties (under "Signing"). It compiles fine, but when I transfer it to my test server and try to re-register it again, I get this:

C:\Windows\Microsoft.NET\Framework\v4.0.30319>regasm c:\inst\MyComComponent.dll /codebase
Microsoft (R) .NET Framework Assembly Registration Utility 4.0.30319.1
Copyright (C) Microsoft Corporation 1998-2004. All rights reserved.

RegAsm : error RA0000 : Failed to load 'c:\inst\MyComComponent.dll' because it is not a valid .NET assembly

I beg your pardon!?!?!? What happened here - and how to fix it??

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Obviously you can ignore the warning. Does regasm successfully register the signed thing on the first machine? – sharptooth Jul 01 '15 at 11:48
  • Maybe this helps http://blogs.msdn.com/b/suzcook/archive/2003/05/29/57120.aspx - the section about BadImageFormatException – sharptooth Jul 01 '15 at 11:50
  • @sharptooth: it *seems* that RegAsm does work just fine - I can create those COM objects from a non-.NET environment like Delphi just fine. Just makes me wonder why this warning is even shown? And still : why does RegAsm reject a **signed** .NET assembly - after it's suggesting to do just that!! – marc_s Jul 01 '15 at 11:56
  • Maybe your server is 64bit? In that case try using the 64bit version, C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe – cdel Jul 01 '15 at 11:59
  • @cdel: it is 64-bit, but the .NET DLL was built with the "x86" platform model. And on the non-signed .NET DLL, the 32-bit version of RegAsm works just fine ..... – marc_s Jul 01 '15 at 12:00
  • Anyway does the problem happen on both dev and prod machines? – sharptooth Jul 01 '15 at 12:08
  • I asked about the warning earlier http://stackoverflow.com/q/4864892/57428 – sharptooth Jul 01 '15 at 12:08
  • @sharptooth: I'm only on DEV for now - and while **I** have no trouble just ignoring that warning, I'm afraid my customer won't be quite as happy to have an installation step show such a warning..... – marc_s Jul 01 '15 at 12:52
  • Whatever. Does *Failed to load* happen on dev? – sharptooth Jul 01 '15 at 13:05

0 Answers0