Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2005

Tip: Looking for answers? Try searching our database.

Writing COM component in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jan Eliasen - 21 Sep 2005 13:41 GMT
Hi

I am terribly sorry to disturb you all with this probably very simple
question... but I have searched the net for two hours, and there are a
lot of webpages out there with the words n it that I have tried
searching for :-/

Anyway, I need a simple quick guide to how I cna write a dll in C#
that I can register as a COM component and then I'd like to call it
from my VBA application in Visio.

I have started Visual Studio ..NET 2003

I have created a new project as a class library

I have entered "Register for COM Interop" in the projects properties

I have entered "[ComVisible(true)]" just above both the class
statement and just above two different methods.

I have written "[ClassInterface(ClassInterfaceType.AutoDispatch)]"
just above the class statement

And I have written
"[GuidAttribute("FE250E36-0897-4a15-ADEF-CA69CD71B8CD"),
ProgId("WM_data.DK.Axapta.Axapta_CAD_Integration.Axapta_CAD_Integration")]"
just above the class statement.

When I compile my code, nothing fails, and in the registry I can now
see my component. Allthoug I have no idea whether is is registered the
right way :-)

In my VBA code in the Visio Macro, I have a line called this:
Set obj =
CreateObject("WM_data.DK.Axapta.Axapta_CAD_Integration.Axapta_CAD_Integration")

It does not fail, leaving me to think that my component is actually
registered correctly. But the error comes when I want to call a
method, ie:
obj.ReceiveDataAndSendItToAxaptaASync (str)

This IS the correct name of the method, and it takes a string as a
parameter. The error I receive is "Object doesn't support this
property or method".

So I must have done something wrong.

Help?
Signature

Jan Eliasen, representing himself and not the company he works for.

Bob - 21 Sep 2005 14:05 GMT
> Hi
>
[quoted text clipped - 17 lines]
>
> I have written "[ClassInterface(ClassInterfaceType.AutoDispatch)]"
It is better and recommended in MSDN that you should not use AutoDispatch
but I doubt this is the cause.

> just above the class statement
>
[quoted text clipped - 15 lines]
> method, ie:
> obj.ReceiveDataAndSendItToAxaptaASync (str)
Can you post the exact signature of this? Does your COM component uses other
.Net Assemblies?

> This IS the correct name of the method, and it takes a string as a
> parameter. The error I receive is "Object doesn't support this
[quoted text clipped - 3 lines]
>
> Help?
Jan Eliasen - 21 Sep 2005 14:20 GMT
>> I have written "[ClassInterface(ClassInterfaceType.AutoDispatch)]"
>It is better and recommended in MSDN that you should not use AutoDispatch
>but I doubt this is the cause.
Should I remove the line or replace it with something else?

>> In my VBA code in the Visio Macro, I have a line called this:
>> Set obj =
[quoted text clipped - 6 lines]
>Can you post the exact signature of this? Does your COM component uses other
>.Net Assemblies?
The signature is this:
public static void ReceiveDataAndSendItToAxaptaASync(string xml)
The method takes the string, loads it into an XMLDocument. Then the
content of one of the nodes in the xml is written to a file on the
c-drive.

Signature

Jan Eliasen, representing himself and not the company he works for.

Jan Eliasen - 21 Sep 2005 14:56 GMT
>Can you post the exact signature of this? Does your COM component uses other
>.Net Assemblies?
Hi

I have it working now.

I removed the "[ClassInterface(ClassInterfaceType.AutoDispatch)]" as
you told me, and I changed the methods from being static to being
"normal" - now it works.

Thanks for your time.

Signature

Jan Eliasen, representing himself and not the company he works for.

Kaustav. - 22 Sep 2005 15:16 GMT
Hi Jan,

does your class library have a parametrized constructor ? If yes, try using
a constructor with no parameters and see if it works.

> Hi
>
[quoted text clipped - 44 lines]
>
> Help?
Jan Eliasen - 27 Sep 2005 10:06 GMT
>does your class library have a parametrized constructor ? If yes, try using
>a constructor with no parameters and see if it works.
Hi

No, it doesn't. But I solved the problem in another way, as you can
see previous in this thread.

Thanks, though :-)

Signature

Jan Eliasen, representing himself and not the company he works for.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.