none
RegAsm : error RA0000 : Failed to load 'C:\Users\Juan Dent\Source\Repos\COM_NET_Interaction\Debug\NETComponent.dll' because it is not a valid .NET assembly RRS feed

  • Question

  • Hi,

    I created a .NET component in a C++ managed class library but the generated DLL is not a valid assembly... What could be the cause of this?

    My program is VERY simple... it is as follows:

    #using <mscorlib.dll>
    
    using namespace System;
    
    
    
    namespace NETComponent {
    
    	public interface class IGreeter
    	{
    		String ^ Greet();
    	};
    
    	public ref class Greeter : public IGreeter
    	{
    	public:
    		String^  Greet() override
    		{
    			return "Hi everyone from a .NET component";
    		}
    	};
    }

    What am I doing wrong?

    Please, this is my first .NET component in managed C++ using VS 2017 v15.7.4.

    Regards,

    Juan Dent


    Juan Dent

    Thursday, June 28, 2018 6:28 PM

Answers

  • you are using the RegAsm version matching the platform?
    I get you error, when I compile for x64, but then use the x86 regasm.
    When you compile for x86: C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe
    when you compile for x64: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe
    • Edited by EckiS Friday, June 29, 2018 4:29 AM
    • Marked as answer by Juan Dent Friday, June 29, 2018 5:47 PM
    Friday, June 29, 2018 4:29 AM

All replies

  • when this is everything in the assembly: there is nothing to register in for COM, so I wonder what you want to do with RegAsm?

    Thursday, June 28, 2018 7:21 PM
  • Well I want this .NET component to be usable as a Com object in unmanaged code. What am I missing?

    I took the example and adapted it from an old book - it seems many things have changed. that book uses __gc __interface instead of ref interface.

    Please some guidance here!

    Thanks!!

    Juan


    Juan Dent

    Thursday, June 28, 2018 7:55 PM
    • Edited by EckiS Thursday, June 28, 2018 8:39 PM
    Thursday, June 28, 2018 8:36 PM
  • I placed ComVisibleAttribute(true) in all interfaces and classes to no avail. Regasm still says the DLL is not a .NET assembly.

    My Assemblyinfo.cpp contains:

    #include "stdafx.h"
    
    using namespace System;
    using namespace System::Reflection;
    using namespace System::Runtime::CompilerServices;
    using namespace System::Runtime::InteropServices;
    using namespace System::Security::Permissions;
    
    [assembly:AssemblyTitleAttribute(L"NETComponent")];
    [assembly:AssemblyDescriptionAttribute(L"")];
    [assembly:AssemblyConfigurationAttribute(L"")];
    [assembly:AssemblyCompanyAttribute(L"")];
    [assembly:AssemblyProductAttribute(L"NETComponent")];
    [assembly:AssemblyCopyrightAttribute(L"Copyright (c)  2018")];
    [assembly:AssemblyTrademarkAttribute(L"")];
    [assembly:AssemblyCultureAttribute(L"")];
    
    [assembly:AssemblyVersionAttribute("1.0.*")];
    
    [assembly:ComVisible(true)];
    
    [assembly:CLSCompliantAttribute(true)];
    

    Any ideas?

    Regards,

    Juan


    Juan Dent

    Thursday, June 28, 2018 9:06 PM
  • you are using the RegAsm version matching the platform?
    I get you error, when I compile for x64, but then use the x86 regasm.
    When you compile for x86: C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe
    when you compile for x64: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe
    • Edited by EckiS Friday, June 29, 2018 4:29 AM
    • Marked as answer by Juan Dent Friday, June 29, 2018 5:47 PM
    Friday, June 29, 2018 4:29 AM
  • Hi Juan Dent,

    Thank you for posting here.

    For your question, what is the .net framework version of dll? If you do not know about this, please check with the MSDN document How to: Retrieve the .NET Framework Version (C++/CLI).

    https://msdn.microsoft.com/en-us/library/wb281930.aspx?f=255&MSPPError=-2147217396

    And then, what is the corresponding .net framework version of RegAsm.exe? Each version of .net you have installed has it’s own version specific version of RegAsm.exe. Please check the version of RegAsm.exe and use the correct one,.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, June 29, 2018 7:31 AM
    Moderator