Home » C# Programming

Deploying a C# COM DLL

A C# developer has created a C# COM DLL which I use in an IIS7 Native Module (C++). The problem is where to place this DLL. Unlike native COM which specifies the DLL location, the registry CLISD InprocServer32 entry for C# is a generic mscoree.dll.

I was first told to place the DLL in the same folder as the exe making the COM calls. That works but is unacceptable in my case.  This C# DLL is called by a native module DLL which runs under the IIS application w3wp.exe in the system32/inetsvr folder. I really want to avoid deploying to a windows system folder if at all possible.

I was next told to extend the PATH variable to include the directory where I want to place the DLL. This did not work. The path has no effect.

Is there another option for allowing the C# DLL to be located in a folder different from the exe?


2 Answers Found


Answer 1


I am not sure, that I understood it completly right.

The regasm.exe has a /codebase parameter that could be used. http://msdn.microsoft.com/en-us/library/tzat5yw6(VS.71).aspx, "Creates a Codebase entry  in the registry. The Codebase entry specifies  the file path  for an assembly that is not installed in the global assembly cache. You should not specify this option  if you will subsequently install the assembly that you are registering into the global assembly cache. The assemblyFile argument that you specify with the /codebase option must be a strong-named assembly."
==> But is it a com  Component or not?

You can register the DLL in the GAC. gacutil /i is the command required for that. Then the assembly is found in case  software is bound to it.

And the last thing you could do (but which I never did so far) is using the configuration file. So for example, you could modify the machine.config file. (http://msdn.microsoft.com/en-us/library/ms229697(VS.90).aspx) and specify the search paths in there (http://msdn.microsoft.com/en-us/library/4191fzwb(v=VS.90).aspx)

With kind regards,



Answer 2

Thanks Konrad, those are very helpful suggestions which I'll try.



I have a VB.NET application that is utilizing a COM component of an Open Source PDF creator called PDFCreator.  Myself and my end users have this PDFCreator tool already installed.  In my app, I add as a reference the COM executible for PDFCreator, and it attaches a dll called Interop.PDFCreator.dll.  When I run this tool on my own machine it works just fine,  but when I deploy the application to others using ClickOnce, the processes that calls the PDFCreator functions fails.  I did some reading and it seems for normal setup deployment, you can set the register flag to "vsdraDoNotRegister", however I cannot see how to do that with my app.  Secondly, I read that changing the .dll Isolated property to True might do the same thing, however this causes the code to fail in the build process.  Any thoughts on how I set this up?  Perhaps i can't do this with ClickOnce?



A C# developer has created a C# COM DLL which I use in an IIS7 Native Module (C++). The problem is where to place this DLL. Unlike native COM which specifies the DLL location, the registry CLISD InprocServer32 entry for C# is a generic mscoree.dll.

I was first told to place the DLL in the same folder as the exe making the COM calls. That works but is unacceptable in my case.  This C# DLL is called by a native module DLL which runs under the IIS application w3wp.exe in the system32/inetsvr folder. I really want to avoid deploying to a windows system folder if at all possible.

I was next told to extend the PATH variable to include the directory where I want to place the DLL. This did not work. The path has no effect.

Is there another option for allowing the C# DLL to be located in a folder different from the exe?

I have a precreated .net Dll. This dll does not have Classes that are COM callable would I be able to create a reverse interop? i mean is there a possibility to convert a already existing .net dll to COM dll?


I developed a project to monitor remote security stations.

In order to communicate with this security stations ive created c++ com object that implements protocol and most important use cases.

One of such use cases is downloading and storage of telemetry data.

I found out that most efficient way to store large amounts of binary data to SQL Server is to use BulkCopy functionality from ADO.NET

since SDK is c++ COM object ive created com wrapper around BulkCopy functionality and i load it into my C++ COM enviroment when i need it.

Everything works ok. 

Now i have this new project to create windows service to monitor and save some data from security stations into SQL.

Ive created this project to be .net windows service that uses C++ SDK in order to connect to stations and store data to SQL.

In order to simplify debug i run it as a console application in debug configuration and as windows service mode in release configuration.

When it runs as console application it works as it should and all data is received and saved.

However when i try to run it as Windows Service, it fails to load ADO.NET wrapper for BulkCopy functionality.

In other words when i load .net dll to c++ com object that created in windows console application - everything is working.

But if i try to load .net dll to c++ com object created in windows service- it fails to load .net dll.

What may cause such a problem?




I have just installed Windows Phone Developer Tools CTP - April Refresh and created a new project. But when i try to run it on the emulator i get this error message from Visual Studio.

Unable to cast COM object of type
'Microsoft.VisualStudio.DeviceConnectivity.Interop ConManServerClass'
to interface type
This operation failed because the QueryInterface call on the COM
component for the interface with IID
'{E40AE9A4-02EB-4145-9F61-70E67A7B62C1}' failed due to the following
error: No such interface supported (Exception from HRESULT:
0x80004002 (E_NOINTERFACE)).

I have tried both Visual Studio 2010 Express for Windows Phone and Visual Studio 2010 Professional with the same result. I have also tried to repair/reinstall CTP but the error persist.

Can anyone tell what is wrong and how i can fix it?

Best regards



Compiler Error Message: BC30002: Type 'URLINTERFACELib.EnomURL' is not defined.

Source Error:

Line 9:          'Check if domain name is available
Line 10:
Line 11:         Dim enom As New URLINTERFACELib.EnomURL  <-- ERROR
Line 12:         Dim strReturn As String
Line 13:

I am using a COM DLL in my BIN folder URLINTERFACELib

On my test machine I simply added a REFERENCE via Visual Studio and everything worked find. When I deployed the source code to our remote server. It did not work any more.

I guess our remote server is missing a reference, since I could not easly add a reference like in Visual Studio.

I also recognized that Visual Studio created a second file in i bin folder called Interop.URLINTERFACELib.dll. I also copied Interop.URLINTERFACELib.dll to the remote server but this did not help.

On the remote server i used regsvr32 to register the dll. but this also did not work.

Thanks for helping

c:\windows\system32\inetsrv> "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_32\System.Web\\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\\System.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\\System.ServiceModel.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\assembly\dl3\121a21dd\6a5ad5f7_2131c901\ChilkatDotNet2.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualC\\Microsoft.VisualC.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\1.0.61025.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.WorkflowServices\\System.WorkflowServices.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\assembly\dl3\c0c5f2b4\5e6b061c_95edc701\CuteEditor.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\\System.Xml.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\assembly\dl3\811de8c9\5cf28afa_f1f7c701\App_Licenses.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel\\System.IdentityModel.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\\System.Drawing.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\\System.Web.Services.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\assembly\dl3\68ea53cb\7e5e0ef8_f1f7c701\FlickrNet.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel.Web\\System.ServiceModel.Web.dll" /R:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\assembly\dl3\f937e664\6a29f059_f2f7c701\DundasWebChart.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization\\System.Runtime.Serialization.dll" /out:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\App_Code.r62fgocx.dll" /debug- /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls  "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\App_Code.r62fgocx.0.vb" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\App_Code.r62fgocx.1.vb" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\App_Code.r62fgocx.2.vb" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\App_Code.r62fgocx.3.vb" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\App_Code.r62fgocx.4.vb" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\App_Code.r62fgocx.5.vb" "c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e1192e2d\9e6d072f\App_Code.r62fgocx.6.vb"


Not sure if this is the right forum for this... but here goes...

I've developed a windows service application that uses the FaxComExLib to monitor my faxqueue table in my database, and send/manage the fax queue on my fax server.  I had it running completely fine for over a year. I then moved my database and had to change a simple database connection string in the application. However in that time I switched computers and have so upgraded and compiled it with VS 2010 and .NET 4.

I use the installutil from the command line to install the service. It installs fine, and I can start it.When I start it however, it throws an error and stops any further processing (although the service remains started)

I tried installing it on an XP machine and received this error:

Retrieving the COM class factory for component with CLSID {CDA8ACB0-8CF5-4F6C-9BA2-5931D40C8CAE} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

When it installed it on the Windows 2003 server that also runs the fax on it, i get this simple error:

Exception from HRESULT: 0x80040200

I've googled for days on this and am stuck... I can't get past these errors and get the service running again.

Well.. almost... I can run it on my Windows 7 development computer... but that is not ideal!



When running my program in Debug or Release (VS2008) it works fine.

I add a setup project (recommended method of distribution?) and build a setup.msi.

After installation i get an error when running the exe: system.runtime.interopservices.comexception. This happens both on my PC, and another PC.

I have a reference to a COM object CoDeSys Type Library 1.4 in my project, and during call (not creation) to a method (openproject), i get this error.

In my setup project, 2 items have been added automatically:

CoDeSys.tlb, this is marked as DoNotRegister as target machine is supposed to have this already installed, and i should not overwrite that registration.

Interop.CodeSys.dll, This is marked as DoNotRegister.

Both files are automatically copied into the target directory.

I have tried reinstalling Codesys.

Where am i failing?



Hi, I need some help please. I've created a Interop User Control (IUC) wich is hosted on a VB6 form. My development machine has VB6, VS2005, Microsoft Interop Forms Toolkit 2.0, running on Win7 Ultimate 64-bit. I've also managed to deploy this hybrid application using ClickOnce and Reg-Free COM (just to keep things clear, to deploy my application I used a winform application because is a requirement to use ClickOnce).

The IUC allows me to consume a Web service and download a RecordSet containing a Image (and some other strings). In my VB6 form code, I have an Image control named Image1.

I try to set Image1.DataSource = myRS , where myRS is an object of type ADODB.RecordSet.

And here's the known story: "The application works fine in my development machine", but when it's installed in a new machine (XP SP3), it loads ok, but fails in displaying my image in Image1 control.

The error says:
"Run-time error '713':
Class not registered.
Looking for object with CLSID:{59245250-7A2F-11D0-9482-00A0C9110ED}

I've searched for the error on the Internet, and found it is the CLSID of Microsoft Data Binding Collection (MSBIND.DLL). The WinXP SP3 machine does not have MSBIND.DLL.

I tried to deploy C:\Windows\SysWOW64\MSBIND.DLL, using "Build action=Content" and "Copy to output=Alwas", but the error is the same. Another thing I tried was to add a COM reference to Microsoft Data Bind Collection, but still no luck.

What can I do to correctly deploy my application using MS Data Bind with Registration-Free COM, and using ClickOnce?


I've tried to create a COM DLL in C# using VS 2008. I followed everything described here:
- http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/09a6d6f1-2ce1-40f3-b8f4-1472b8343357
- http://blog.stevedoria.net/20051008/creating-com-components-using-visual-csharp-dot-net

The customer succeeds in adding the DLL as a reference in his project, but he can't see any of the methods/properties inside the class. The object browser shows the class, but it looks empty.

This is my code:

namespace MyNameSpace
  public class Utility
    public static void Init(string WSUrl)
//code here

    public static Project GetProjectTemplate(string projectTypeID)
//code here

    public static void CreateProject(Project p, string clientID)
//code here

In VB 6, we can go this far:

Dim r As MyNameSpace.Utility
Set r = New MyNameSpace.Utility
r.Init "a_string_parameter"

The project is built, but at runtime line 3 throws an exception: 438

How can I solve this problem ?


Hi all,

I am trying to develop an  evc++ 4.0 DLL using WCE ATL COM APPWizard project. My intention is to refer this dll in one of our applications running in Windows Mobile 6.0 devices.This application is written in EVB 3.0.

I am able to create this DLL using evc++ 4.0 and i am able to register this dll in the device successfully. But when i try to refer this DLL from evb 3.0 application it is throwing an error saying that unable to create activex object. I am trying to create object of this dll using this piece of evb code.

dim objExcel;

Set objExcel = CreateObject("ExcelObject.Excel");


But, following the same steps, when i created a DLL using evc++ 3.0 WCE ATL COM AppWizard project, i was able to refer this dll susccessfully  from an evb 3.0 project.

My question is, Can I refer a latest version DLL (using evc++ 3.0 targetting Pocket PC 2003 devices) in EVB 3.0 projects ?

This evb application is going to run finally in Windows Mobile 6.0 devices and above..


Thanks in advance,


when i try to register a COM dll in windows xp...its working......but when i register in windows 7 it throws an error saying "Dll Register Entry Not found"..... Can any help me in finding out the exact way of registering it.....now i am using regsvr32........i tried all combinations of it like /i /n....etc.......

Hello all

I have been for a while now trying to get a Web Service dll build in Visual Studio Express 2008 running in MS Word 2003s VBA.


The library is build with C# in Visual Studio Express 2008 as a .NET library. The C# sources where autogenerated from WSDL files and then adapted to VBA (C# long != VBA long, array passing by value and ref issue).

The library works well in a C# .NET Testapplication built in VS Express 2008.

In order to make the library a COM interop library, I used sn.exe to generate a strong name key file that is used by Visual Studio to make the lib strong named. I regasm'd it with /tlb and /codebase option after which all the classes can be found in the registry, also the SoapExtension class named "SessionExtension".

I furthermore tried:

to use the app.config file of the testapplication, renaming it to winword.exe.config and placing it in the winword installation path: result was that Word would issue an run time error hex 80131902. to instanciate the SoapExtension "SessionExtension" programatically the way describled in Mike Bouk's RAM "Programatically Registering SoapExtensions Redux": when trying to run the VBA code out of MS Word, Word would exactly tell me which library could not be loaded (Name, culture, key etc). then to register my library with gacutil to the GAC. After doing so, Word does not complain anymore but does not seem to use the SessionExtension class either.

The only thing that seems to be missing is the SoapExtension, the rest of the communication work well so far (I always chekced with Wireshark if the the session id was added to the soap header and what was sent forth and back).


How do I get the COM interop to use the/my SoapExtension "SessionExtension" class in the Office VBA enviroment?

I would like it better to have the lib do the job of loading the SoapExtension instead of deploying the always same winword.exe.conifg, excel.exe.conifg, powerpoint.exe.config access.exe.config etc. to all of our users installation path(s) (avoiding issues such as having access to the installation directory, multiple config files per app etc).

But finally I would already be a happy man if it worked at all.

Thanks for any help.

Here what the conifg file looks like:

<?xml version="1.0" encoding="utf-8" ?>
        <add type="PolarionVbaWS.SessionExtension,PolarionVbaWS"
        group="High" />
    <bindings />
    <client />


Firstly, I was referred here after posting the following threads:


The problem:

I have an existing HTML based application which has been working in XPProSP2,SP3 with IE6 as well as IE8 (haven't tried IE7 though), and now several users are switching over to Windows7, and my application does not function properly in W7 where my COM objects are not being instantiated on my HTML page as they are in XP.
My application uses ShowHTMLDialogEx to display my HTML page;My COM objects are embedded on the HTML page using the <object> tag, which encloses an error message (being displayed in W7) in case the objects cannot be instantiated;All of my COM objects are marked Safe for Scripting, they are however not digitally signed;
Everything is implemented in ATL (Visual Studio 2008);In W7 my page does load and is displayed, just without the objects that are supposed to be "alive" on the page.

I have tried all sorts of things like Run as Administrator (even though the user account I started off with is a member of the W7 local machine's Administrators group), the permissions inherited from the parent folder are also Full Control.

After much Googling (sorry I avoid 'Binging' as much as possible), I also tried creating a new local administrator user account which did not solve my problem. I have also tried setting all the zones in IE8 to the least secure settings - including Restricted sites, and that also did not work.

In XP, ShowHTMLDialogEx effectively bypasses all "security checks", and allows scripts and COM to run without any prompts or other impedance, how can I get this to work in Windows7?

@mods, please move this thread with a redirect if there is a more relevant forum it should be in.
We have an ASP.NET web application, it consuems COM dll (COM Server (dll) created from VFP) for some processing. Web application is working fine in x86 servers.

It gives the following error message in x64 servers.

Retrieving the COM class factory for component with CLSID {} failed due to the following error : 80040154

To enable IIS 6.0 to run 32-bit applications on 64-bit Windows, I changed Enable32BitAppOnWin64 to true.

To change this property, did the following
Open Command prompt
Navigate to folder (%systemdrive%\Inetpub\AdminScripts directory)
Executed the following
cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 “true”

After setting Enable32BitAppOnWin64 to true, all the websites that are there in the server is throwing "Service Unavailable" error message.

Registering the VFP dll succeeds in x64 environment,
Accessing the DLL from VFP is working fine
Running the web application from Visual Studio IDE (debug mode) is working fine.

Any help will be really apprecated.

Hi all,


Does anyone know how to automatically register a DLL in run-time or just possible to integrate it into an exe file?

This is so I can call COM components that require that DLL registered without first registering the dll using 'regsvr32 <dll>'. I want to do this so that I can just call a single exe and then it does it all, instead of having to register the dll first, then call the exe. (Kind of like to make it faster and time-saving; ex. if I have to call it in many computers).


I took a look at Registration-Free Activation of COM components: http://msdn.microsoft.com/en-us/library/ms973913.aspx#rfacomwalk_topic4.

However, when I import the dll I need (smsmsgapi.dll), it says fatal error C1083: Cannot open type library file: 'd:\my files\lean's files\assignment 13\sms_sdk\smsmsgapi.dll': Error loading type library/DLL. But if I do it using the DLL I create from the steps in the link, it compiles correctly.


I would like to ask for suggestions or comments regarding this.


Thank you!


I've been using IKVM.NET to make .NET DLLs from my java classes, which has been working fine.  Now, I've been asked to make these .NET DLLs COM accessible with early binding support (so that Intellisense works) that can be used in Excel VBA.  If I just make a tlb file from an IKVM.NET-created DLL and add it as a reference in Excel VBA, I can see the classes in the Excel VBA object browser, but there are no members or methods visible.

I'm trying to avoid writing a bunch of wrapper code in Visual Studio, so I've been looking for a way to do this by disassembling/modifying/reassembling the .NET DLLs created by IKVM.NET.  I disassembled a .NET DLL I made with Visual Studio that works fine with the Excel object browser, and tried to compare the two il files.  I've found some differences (i.e. InterfaceTypeAttribute) and made some tweaks to the original il file, reassembled, and created a new tlb, but am still only getting empty classes in the Excel object browser.

Any thoughts on what might need to be done to the il file before reassembly?  Is there a simple way just add one of the IKVM.NET DLLs to a C# project and make it accessible to COM early binding without having to write a wrapper for every class?



In my C# solution I have a Class Library (DLL) project and it has properties set for "Register for COM interop" and "Make assembly COM-Visible". When I build the solution, it creates and registers the DLL correctly as I can see it added to the list of COM references on my PC. I can add the reference to VBA code for Access 2010 successfully.

I created a "Setup and Deployment" project using the Setup Wizard, and used it to deploy my COM DLL via an MSI file. However, when I run the MSI file on another PC it finishes successfully and creates the folder/files but doesnt register my COM DLL on the new PC. I dont see a COM reference for the DLL on this PC to put in VBA code.

What am I missing, and how do I get the vdproj to register the COM DLL?



The issue: A native vcproj was built by Visual Studio Team System 2008 with SP1. The output is expected to be a COM dll. But this dll was not able to be registered. The error code returned by regsvr32 is: 0x80029c4a.

By debugging, we found the COM dll resource was messed up. Open the dll file by Visual Studio Resource Editor, we found that the resource for "TYPELIB" was put under "REGISTRY". From the resource editor, there were four sections: "REGISTRY", RT_MANIFEST, String Table and Version. Under "REGISTRY", there are two items: 1 and 101. Actually the item 1 should be in section "TYPELIB" which however was missed in this dll resource.

We are now using NAnt to build a big system which includes many VS projects (nearly 400). By batching, this issue happened randomly, frequently recently but disappear if manuallly rebuild this very project.

Does anybody experienced the same issue before? Please let me know if any suggestions or comments. Thanks.



I'm getting quite mixed up with all the infos I'm getting about dll's! Please HELP!

I have a .net dll and would like to use it in LabWindows (C). In order to have a list of the functions present in my dll I used DLL Export Viewer and obtained some "exported functions" but also "COM Method" and "COM Property". The COM Method and Property functions are the ones that interest me. The problem is that these functions don't seem to have an adresse and the name are of type: Class::MOVE. Which, I think, is a C++ way of calling a function.

So here are my questions:

1) What does COM method/property mean?

2) How can I access these functions using the LoadLibrary() and GetProcAdresse() functions?

3) Will these functions be compatible with C and not C++ programming?



<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure