How to use Regasm.exe to register a COMl for an ASCOM project - dll

I am trying to build a simple solution but always get the following error:
Severity Code Description Project File Line Suppression State
Error The assembly 'ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7' is not registered for COM Interop. Please register it with regasm.exe /tlb. ASCOM.ML16200.DeviceClass1
Error The assembly "C:\Users\tonyb\source\repos\ASCOM.ML16200.DeviceClass1\ASCOM.ML16200.DeviceClass1\bin\Debug\ASCOM.ML16200.Camera.dll" could not be converted to a type library. Type library exporter encountered an error while processing 'ASCOM.ML16200.Camera, ASCOM.ML16200.Camera'. Error: Error loading type library/DLL. ASCOM.ML16200.DeviceClass1
I've tried using the following command within Visual Studio Powershell, but it always fails:
PS C:\Users\tonyb\source\repos\ASCOM.ML16200.DeviceClass1> regasm.exe ASCOM.ML16200.Camera.dll /tlb
Microsoft .NET Framework Assembly Registration Utility version 4.8.4084.0
for Microsoft .NET Framework version 4.8.4084.0
Copyright (C) Microsoft Corporation. All rights reserved.
RegAsm : error RA0000 : Unable to locate input assembly 'ASCOM.ML16200.Camera.dll' or one of its dependencies.
PS C:\Users\tonyb\source\repos\ASCOM.ML16200.DeviceClass1>
Can anyone please tell me how to properly register this .dll?

I can assume that this will help you:
1. Run Visual Studio as an administrator. And try to rebuild the project, then start debugging (so Visual Studio will try to register the .dll file). This method worked for me on Visual Studio 2015.
But when developing a driver for Focuser in Visual Studio 2019, this method did not work for me.
My screenshot Focuser error registration
2. Registering ASCOM .dll file in manual mode:
Open Developer Command Prompt as Administrator
Now using the regasm tool, register the .dll file
My screenshot example, manual register
Now you can start debugging the .dll file.
P.S.
Do not forget, you cannot debug .dll files directly, use other applications for this. For example ASCOM provides ready-made templates for such applications

Related

Adding DLL in Visual Studio 2013 causes Compiler Error -107374181 (ERROR_ACCESS_DENIED)

I am trying to add a reference to a dll, but when I compile the project I get:
Compiler Error Message: The compiler failed with error code -1073741819.
I have tried:
changing the security permissions on the dll to allow full control
running visual studio as administrator.
I have added the dll with copylocal = false, but it fails at runtime with a "file not found" error.
I created a separate project with the same framework version (4.5) and was able to add the dll without any trouble, but unfortunately I need to add it to the existing legacy project.
The legacy project source files are in GitHub, but the bin folder where I am adding the DLL to is not in Github.

Visual Studio 2015 Error "Cannot resolve Assembly or Windows Metadata file 'Windows.winmd'"

I have a project, on another PCs can build it.
But my main pc can't.
Errors:
1: "Cannot resolve Assembly or Windows Metadata file 'Windows.winmd'"
2: "Type universe cannot resolve assembly: Windows, Version=255.255.'255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime."
I tried reinstall the WIN10 SDK and the VS2015, but the errors are same.
It is an Universal Store App.
I could solve the problem. I uninstalled all SDK, all VS, all developer tool. After reinstall the VS can build my project.

Modification assembly (Dll) version without rebuilding using Ilmerge didn't work

I am trying to change the Dll version without rebuilding the code.
Reason: We are trying to change minor configurations in our server application this doesn't require any code changes in our client. We dont want take any risk in rebuilding the code because there are no changes to the code.
So I was trying to update just the version of the Dll using Ilmerge.exe tool.
I ran the below command but I am not able to change the version of the output assembly file. I see same old version number in output dll.
Below is the command which I ran (copied from ilmerge commnad log output), I didn't get any kind of errors.
ILMerge version 2.12.803.0
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge C:\Users\Administrator\Desktop\SS_Logs\SS_Modify_Dll_Version\SS_Library.dll /lib:C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies /lib:C:\Users\Administrator\Desktop\SS_Logs\SS_Modify_Dll_Version /keyfile:C:\Users\Administrator\Desktop\SS_Logs\SS_Modify_Dll_Version\SS_key.snk /target:library /targetplatform:v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0 /out:C:\Users\Administrator\Desktop\SS_Logs\SS_Modify_Dll_Version\temp_SS.dll /ver:2.2.0.66 /ndebug /log:ilmerge_Log.txt

How to run .NET 4 code analysis on build server

On a Windows Server 2003 R2 with .NET 4 SDK but without Visual Studio 2010, I have tried building a Visual Studio 2010 solution with
msbuild MySolution.sln /p:RunCodeAnalysis=true
but that fails.
What is required to run code analysis on such an environment?
I get this error message:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(129,9): error MSB6003:
The specified task executable "FxCopCmd.exe" could not be run.
Could not load file or assembly
'Microsoft.VisualStudio.CodeAnalysis.Sdk, Version=10.0.0.0, Culture=neutral, PublicKeyToken= b03f5f7f11d50a3a'
or one of its dependencies.
The system cannot find the file specified.
I have installed FxCop from the SDK and without luck pointed the variable FxCopDir to the installed location of FxCopCmd.exe, and also setting this registry entry to that location:
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev#FxCopDir
I had the same problem on my MSBuild server and fixed it by:
Installing Windows SDK 7.1
Setting up the registry keys FxCopDir and StanDir in HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev (in Win32).
I then copied over from the dev PC, to the FxCop folder on the build server, the following:
The folder Rule Sets (default installation target is here: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop)
Microsoft.VisualStudio.CodeAnalysis.Sdk.dll
Microsoft.VisualStudio.CodeAnalysis.Phoenix.dll
phx.dll
Do a search for them on your dev PC with Visual Studio installed to locate them.
Then use the .NET 4.0 version of gacutil.exe to install Microsoft.VisualStudio.CodeAnalysis.Sdk.dll to the GAC.
You should then be able to run code analysis as part of an MSBuild build and have it work properly.
An alternative to FxCop would be to use the tool NDepend that lets write Code Rules over C# LINQ Queries (namely CQLinq). Disclaimer: I am one of the developers of the tool
More than 200 code rules are proposed by default. Customizing existing rules or creating your own rules is straightforward thanks to the well-known C# LINQ syntax.
Rules can be verified live in Visual Studio and at Build Process time, in a generated HTML+javascript report.
Another option might be calling FxCop executable as a build task (from msbuildtasks), saving the result as an XML file that can be parsed within most of the CI tools (like Hudson and CC.NET)

How to use visual leak detecter ( vld ) for com/atl dll projects?

I included vld.h file in my activex dll project. when i try to compile my project from visual studio 2008.I am getting the following error,
1>Registering output...
1>Project : error PRJ0050: Failed to register output. Please ensure you have the appropriate permissions to modify the registry.
How to use visual leak detecter for com/activex dll projects?
I don't think this has anything to do with the 'visual leak detecter' (sic?)... I'm not familiar with it.
Anyway, the PRJ0050 error occurs because Visual Studio attempts to auto-register the DLL generated by the project, using a post-build step (see Project Settings), and you are not logged in as a user with permission to modify the registry.
So, either Run Visual Studio as an administrator (if you're on Windows Vista), if you want to allow auto-registration, or remove the auto-registration post-build step from the project.