paul K
paul K

Reputation: 13

problems registering and using a DLL assembly

I use Visual Studio 2015 community on my Win 10 dev machine. I built a DLL and registered it for COM interop. In the same solution I have a test console application which I use to test/ debug the DLL. Pleased to say it works really well. The code is version controlled on github and my typical workflow is to commit locally and push to my remote on github.com

So my problem is that I cloned the repo onto a diffeent windows 10 machine which has Visual Studio Community 2022 installed. When I load the solution and build it I get the usual success message. However, when I run it in VS (Debug -> Start debugging), when the console application tries to reference the DLL, I get the following error message error displayed

I appreciate more information may be required.

As usual I suspect it's something I have or haven't done, but I'm a bit stuck. Thanks for any ideas.

I thought it might help if I registered the codebase from a developer command prompt. I used the prompt to navigate to the debug folder and used the following command: regasm .DLL /codebase (substituting the driver name)

This actually worked, but the problem is that if I change the code and build, when I run it the error reappears. I have to use regasm after each build in order to run the code.

My knowledge and experience (especially in terms of windows registry) is limited, I am trying to learn about stuff using the MS learn pages.

Thanks for reading this and for any pointers for things to try. Paul

Upvotes: 0

Views: 645

Answers (1)

paul K
paul K

Reputation: 13

Background The Visual studio solution was originally built in 2015 using VS 2015 community it consists of two components - the driver DLL and a test console exe used to test and debug the dll. In that version of VS the applications were built as 32 bit. It all worked fine. The code is on Github.com

New circumstances So now on the different machine where I cloned the repo, the version of VS is VS 2022 community which is of course a 64 bit application. The test application was set to compile as x86 (32 bit). The driver was compiled as AnyCPU but is registered as a 64 bit object - which of course won’t run in a 32 bit application.

Steps taken to resolve the issue

  1. Start VS as admin

  2. Clean the build

  3. Change the assembly version number to a fixed version with no wildcard

  4. Create and apply a new GUID for the driver

  5. Build a debug version which creates a 64bit COM registration

  6. Register the driver in the 32bit portion of the registry using the following command from a command prompt in the bin\debug folder.

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Regasm .dll /codebase

Following the above steps the code now runs as expected.

I am grateful to Peter Simpson at the ASCOM initiative for help with the above.

Upvotes: 0

Related Questions