473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

strange error -- COM DLL is not installed correctly?

Hello everyone,
I am migrating my C++ COM server to managed code (C# COM server). I am using
the same client to use the same COM class in COM server. The C++ version COM
server works properly, but when using the C# COM server, there is a strange
error indicating dll is not installed correctly (data link error).

I have tried to delete the DLL at the same time to test whether the DLL
could be found correctly when the client is invoking the DLL, and Windows
system reports error message indicating that the DLL is in use -- so I think
the DLL should be able to found. Why COM client will report the strange error
indicating the DLL is not installed properly (C# COM server)?

Any check list to solve this issue?
thanks in advance,
George
Jul 16 '07 #1
8 1883
"George" <Ge****@discussions.microsoft.comwrote in message
news:D8**********************************@microsof t.com...
I am migrating my C++ COM server to managed code (C# COM server). I am
using
the same client to use the same COM class in COM server. The C++ version
COM
server works properly, but when using the C# COM server, there is a
strange
error indicating dll is not installed correctly (data link error).

I have tried to delete the DLL at the same time to test whether the DLL
could be found correctly when the client is invoking the DLL, and Windows
system reports error message indicating that the DLL is in use -- so I
think
the DLL should be able to found. Why COM client will report the strange
error
indicating the DLL is not installed properly (C# COM server)?
How did you install the DLL? When a COM DLL is developed with C# you have
to use REGASM instead of REGSVR32.
Jul 16 '07 #2
Thanks Alberto,
If I select Register for COM in build page of a C# project in Visual Studio
2005, do I still need to use Regasm to register?
regards,
George

"Alberto Poblacion" wrote:
"George" <Ge****@discussions.microsoft.comwrote in message
news:D8**********************************@microsof t.com...
I am migrating my C++ COM server to managed code (C# COM server). I am
using
the same client to use the same COM class in COM server. The C++ version
COM
server works properly, but when using the C# COM server, there is a
strange
error indicating dll is not installed correctly (data link error).

I have tried to delete the DLL at the same time to test whether the DLL
could be found correctly when the client is invoking the DLL, and Windows
system reports error message indicating that the DLL is in use -- so I
think
the DLL should be able to found. Why COM client will report the strange
error
indicating the DLL is not installed properly (C# COM server)?

How did you install the DLL? When a COM DLL is developed with C# you have
to use REGASM instead of REGSVR32.
Jul 17 '07 #3
"George" <Ge****@discussions.microsoft.comwrote in message
news:C4**********************************@microsof t.com...
If I select Register for COM in build page of a C# project in Visual
Studio
2005, do I still need to use Regasm to register?
No, Visual Studio does that automatically. You only have to use Regasm if
you want to install the dll manually in a different computer.

Another detail that you may need: The COM consumer needs to be able to
find the DLL at runtime. With an ordinary COM DLL written in a language such
as C++, it is sufficient to register the DLL for the clients to find it,
since the path to the dll is stored in the Registry. This is not enough with
a managed (C#) dll. In this case, the dll needs to be found by the .Net
runtime. One way to achieve this is to copy the dll to the same folder as
the program that is consuming it. Another way is to add a Strong Name and
install the dll into the Global Assembly Cache.

Jul 17 '07 #4
Thanks Alberto!
I am very interested in this method,

--------------------
add a Strong Name and
install the dll into the Global Assembly Cache.
--------------------

But I have never done this before, could you let me know how to configure in
more details?
regards,
George

"Alberto Poblacion" wrote:
"George" <Ge****@discussions.microsoft.comwrote in message
news:C4**********************************@microsof t.com...
If I select Register for COM in build page of a C# project in Visual
Studio
2005, do I still need to use Regasm to register?

No, Visual Studio does that automatically. You only have to use Regasm if
you want to install the dll manually in a different computer.

Another detail that you may need: The COM consumer needs to be able to
find the DLL at runtime. With an ordinary COM DLL written in a language such
as C++, it is sufficient to register the DLL for the clients to find it,
since the path to the dll is stored in the Registry. This is not enough with
a managed (C#) dll. In this case, the dll needs to be found by the .Net
runtime. One way to achieve this is to copy the dll to the same folder as
the program that is consuming it. Another way is to add a Strong Name and
install the dll into the Global Assembly Cache.

Jul 17 '07 #5
"George" <Ge****@discussions.microsoft.comwrote in message
news:4C**********************************@microsof t.com...
I am very interested in this method,

--------------------
add a Strong Name and
install the dll into the Global Assembly Cache.
--------------------

But I have never done this before, could you let me know how to configure
in
more details?
First you need to generate a Key File. You open a Visual Studio Command
Prompt (start->Visual studio->tools) and you enter this command:
sn -k MyKeys.snk

This wil generate the file "MyKeys.snk". You only have to do this once.
Then you store MyKeys.snk in a safe place and you can use it to sign all
your programs.

Next: In the project of the dll that you want to sign with a Strong Name,
find the file AssemblyInfo.cs, open it, and you will find an attribute
called AssemblyKeyFile. There you add the path of your .snk file:

[assembly: AssemblyKeyFile(@"path\MyKeys.snk")]

You should also modify the AssemblyVersion and enter a "fixed" version
number such as "1.0.0.0" instead of the existing "auto-increment" version
number that contains an asterisk.

That's it. You now compile your dll and it will receive a Strong Name. If
you get a "cryptographic error" while compiling, that means that you wrote a
wrong path to the snk file.

Now that the assembly has a Strong Name, you can install it to the GAC.
One way to do this is to execute the command "gacutil -i mylibrary.dll".
Another way is to open c:\Windows\Assembly in Windows Explorer, and then
drag and drop your DLL to that location.

Once you have done this, any .net executable that wants to load your dll
will be able to find it, regardles of the location of the .exe in the
filesystem.

Jul 17 '07 #6
Thanks Alberto,
I have followed your steps to register dll into GAC. I am wondering how to
check from GAC that my dll is actually registered?
regards,
George

"Alberto Poblacion" wrote:
"George" <Ge****@discussions.microsoft.comwrote in message
news:4C**********************************@microsof t.com...
I am very interested in this method,

--------------------
add a Strong Name and
install the dll into the Global Assembly Cache.
--------------------

But I have never done this before, could you let me know how to configure
in
more details?

First you need to generate a Key File. You open a Visual Studio Command
Prompt (start->Visual studio->tools) and you enter this command:
sn -k MyKeys.snk

This wil generate the file "MyKeys.snk". You only have to do this once.
Then you store MyKeys.snk in a safe place and you can use it to sign all
your programs.

Next: In the project of the dll that you want to sign with a Strong Name,
find the file AssemblyInfo.cs, open it, and you will find an attribute
called AssemblyKeyFile. There you add the path of your .snk file:

[assembly: AssemblyKeyFile(@"path\MyKeys.snk")]

You should also modify the AssemblyVersion and enter a "fixed" version
number such as "1.0.0.0" instead of the existing "auto-increment" version
number that contains an asterisk.

That's it. You now compile your dll and it will receive a Strong Name. If
you get a "cryptographic error" while compiling, that means that you wrote a
wrong path to the snk file.

Now that the assembly has a Strong Name, you can install it to the GAC.
One way to do this is to execute the command "gacutil -i mylibrary.dll".
Another way is to open c:\Windows\Assembly in Windows Explorer, and then
drag and drop your DLL to that location.

Once you have done this, any .net executable that wants to load your dll
will be able to find it, regardles of the location of the .exe in the
filesystem.

Jul 19 '07 #7
Thanks Alberto!
I have followed your steps to register my dll into GAC. I am wondering how
to know whether the dll is correctly and actually registered into GAC? Any
tools to check?
regards,
George

"Alberto Poblacion" wrote:
"George" <Ge****@discussions.microsoft.comwrote in message
news:4C**********************************@microsof t.com...
I am very interested in this method,

--------------------
add a Strong Name and
install the dll into the Global Assembly Cache.
--------------------

But I have never done this before, could you let me know how to configure
in
more details?

First you need to generate a Key File. You open a Visual Studio Command
Prompt (start->Visual studio->tools) and you enter this command:
sn -k MyKeys.snk

This wil generate the file "MyKeys.snk". You only have to do this once.
Then you store MyKeys.snk in a safe place and you can use it to sign all
your programs.

Next: In the project of the dll that you want to sign with a Strong Name,
find the file AssemblyInfo.cs, open it, and you will find an attribute
called AssemblyKeyFile. There you add the path of your .snk file:

[assembly: AssemblyKeyFile(@"path\MyKeys.snk")]

You should also modify the AssemblyVersion and enter a "fixed" version
number such as "1.0.0.0" instead of the existing "auto-increment" version
number that contains an asterisk.

That's it. You now compile your dll and it will receive a Strong Name. If
you get a "cryptographic error" while compiling, that means that you wrote a
wrong path to the snk file.

Now that the assembly has a Strong Name, you can install it to the GAC.
One way to do this is to execute the command "gacutil -i mylibrary.dll".
Another way is to open c:\Windows\Assembly in Windows Explorer, and then
drag and drop your DLL to that location.

Once you have done this, any .net executable that wants to load your dll
will be able to find it, regardles of the location of the .exe in the
filesystem.

Jul 19 '07 #8
"George" <Ge****@discussions.microsoft.comwrote in message
news:06**********************************@microsof t.com...
I have followed your steps to register my dll into GAC. I am wondering how
to know whether the dll is correctly and actually registered into GAC? Any
tools to check?
You can use "gacutil -l" to list the assemblies in the GAC.
You can also use Windows Explorer to navigate to C:\Windows\Assembly.
This will display the contents of the GAC.

Jul 19 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jonathan | last post by:
Hello, I want to install the current version 4.0.13 of MySQL on a Win2000 machine in a directory different to the default (C:\mysql). It should be a network drive, as this is backed up by our IT...
1
by: Hemant | last post by:
Why i am getting this error. Server Error in '/' Application Runtime error Please help me out. Thank you
2
by: EmmanuelE | last post by:
Just installed VS2003 and tried a hello world app. Getting 404 error even when I explictly specify the start page in the url. In IIS Mgr (v 5.1), App has .aspx mapped to...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
1
by: intl04 | last post by:
I am getting strange print-related error messages when trying to create (not print!) reports. For example, when I click 'new' to create a report then choose 'design view', I get an error message...
6
by: AlanS | last post by:
I have used Visual Studio for about 8 months. I have developed some ASP solutions. I had to get on with some other things and have not worked with ASP.NET for a couple months. In the meantime, I...
0
by: Al Cohen | last post by:
I just installed Server 2003 Web Edition, and all updates. I thereupon installed a web application that had been working fine for some time on Server 2003 Enterprise Evaluation, and the...
0
by: theintrepidfox | last post by:
Dear Group I came accross a very annoying behaviour of Visual Studio, giving me six hours of headache till I found the solution. This post is mainly for fellow developers for reference as it...
4
by: mcwooq | last post by:
Hi, I just installed the VS.Studio 2005 Team Edition for Developper and encountered severe problems with debugging ASP.NET 2.0 projects. Even newly empty created ASP 2.0 projects can't debug...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.