473,382 Members | 1,529 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,382 software developers and data experts.

Registering a COM Server using C#

Hi All,

I was using VC++ earlier to register COM Server programmatically. What
i do is I use LoadLibrary(Desired COM DLL), then
GetProcAddress("DllRegisterServer"), and then call that function using
the function pointer that GetProcAddress returns. How do i do that in
C#, I tried using the DllImport attribute for calling LoadLibrary and
GetProcAddress, it works but at last GetProcAddress returns a fucntion
pointer ie a FARPROC or barely long, and i don't know how to use it as
a function pointer in C#.

Please help in this regard

Thanks in advance,
Vivek Ragunathan

Jul 21 '05 #1
2 4950
Hi,

If the COM DLL is known at compile time, try to use DllImport directly with
the DllRegisterServer function of your COM DLL and call it.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"VivekR" <Ke*****@gmail.com> escribió en el mensaje
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi All,

I was using VC++ earlier to register COM Server programmatically. What
i do is I use LoadLibrary(Desired COM DLL), then
GetProcAddress("DllRegisterServer"), and then call that function using
the function pointer that GetProcAddress returns. How do i do that in
C#, I tried using the DllImport attribute for calling LoadLibrary and
GetProcAddress, it works but at last GetProcAddress returns a fucntion
pointer ie a FARPROC or barely long, and i don't know how to use it as
a function pointer in C#.

Please help in this regard

Thanks in advance,
Vivek Ragunathan

Jul 21 '05 #2
Vivek,

You won't be able to do this dynamically in .NET 1.1 or before.
However, in .NET 2.0, you can create a delegate with the appropriate
signature, like so:

// The delegate for DllRegisterServer.
[return:MarshalAs(UnmanagedType.Error)]
private delegate int DllRegisterServerFunction();

Once you have that, you can pass the IntPtr representing the value that
GetProcAddress returns to the static GetDelegateForFunctionPointer method on
the Marshal class, and it will return a delegate that you can call to invoke
the method in the DLL.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"VivekR" <Ke*****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi All,

I was using VC++ earlier to register COM Server programmatically. What
i do is I use LoadLibrary(Desired COM DLL), then
GetProcAddress("DllRegisterServer"), and then call that function using
the function pointer that GetProcAddress returns. How do i do that in
C#, I tried using the DllImport attribute for calling LoadLibrary and
GetProcAddress, it works but at last GetProcAddress returns a fucntion
pointer ie a FARPROC or barely long, and i don't know how to use it as
a function pointer in C#.

Please help in this regard

Thanks in advance,
Vivek Ragunathan

Jul 21 '05 #3

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

Similar topics

3
by: Stangonline.com | last post by:
Ok, im familiar with typical troubleshooting of this type on problem, but I do not do any programming myself. Im hoping you guys can help me with an install problem that I am having. I have an...
3
by: Ellen K | last post by:
Hi all, We have standardized on Hyperion as our reporting tool. So far I have only set up a couple of Access databases as data sources for it. Now there is a request to report off our eOn...
6
by: ian | last post by:
Hi All I have a DLL (nahd.dll) that has been supplied to me will a PBX phone system. According to the documentation it is to allow developers to write there own applications to monitor the...
2
by: glenn | last post by:
I have written a COM Server in C# and its working perfectly. I am not ready to deploy to client computers to begin the real testing and am now wondering how to perform. The part that confuses me...
2
by: Helen | last post by:
I've got some clientside script that runs when the selected index of a select box changes. Now I need to swap my selectbox with an ASP.NET radiobuttonlist (to solve some layout issues). I still...
3
by: InteropNut | last post by:
Hi, My ASP.NET application uses the MSOWCF.dll COM component (ms office functions) and it works fine on my computer with MS Office installed. But I am trying to upload the application to my web...
3
by: gaschurman | last post by:
I have a DLL (imagemagick) that I need to use in my site , but the web hosting does not allow me to register the DLL. is there any way to use that DLL refiring to the Path without registering ?...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
I use "Click Once" Deployment from VS2005. Works like a charm. I have to deploy a console app and an MS Access ADP. The console app invokes the ADP. I copy the ADP to the application files to be...
1
by: shivkumar2004 | last post by:
Hi!, I am developing a chat system using vb.net in vs 2005. I am getting the following error while registering the events. error details: System.InvalidOperationException was unhandled...
0
by: shivkumar2004 | last post by:
Hi, I m getting the following error while registering the events on client appl. error: "An error occurred creating the form. See Exception.InnerException for details. The error is: Exception...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.