OK, Ive run my head into this wall for too long. I need help.
I am developing an applicaiton in C# to present a user with a GUI to specify
a configurable list of machines that he wants to listen to the output of.
Specify a filename to shove all of the data (into Excel), and start the whole
thing going. I get that done no problem. The problem comes with the Data.
The data is coming from a different application, and I am not 100% sure of
what it will be written in, so COM says I is the way to get this working. I
provide the other applicaiton with an interface to my class(es) for storing
data, and when this other app uses COM to call my exposed methods, I will
take care of the rest. Easy as pie. Alas, life isnt so good. I think I am
messing up somewhere in the registration of the TLB, or in the C# (this is my
first serious C# app)
My application is contained in one *.cs file, and it handles most of the GUI
stuff, and internal data storage. In another file I have defined the classes
to hold this very important data, some enums to help turn the integers into
strings, and an interface that contains the methods I want to expose to the
outside APP. All of the classes (there are 4) all inherit the same interface
(and implement all 4 methods, though 3 of them are blank returns).
Everything compiles nicely into a nice executable (*.exe).
Now, I run REGASM on the executable file generating a *.tlb file as well as
telling me it registers the classes in the registry (and I can see them in
the OLE/COM object viewer). Everything is looking great.
I need to test to see if the COM works though, and I do not know when/where
the real app is, so I decide to write a simple (I hope) C++ application which
will get the interface I expose, and send the data over to me. This simple
C++ app I view as the client, and the GUI in C# as the server. I hope I am
not innaccurate in those terms.
What I hope to see happening is starting up the C# app, and start it
listening for data, then starting up my dummy client app, and sending data to
the C# application via the exposed COM interface.
However, I cannot instantiate the object or the pointer. I am getting
errors that the file does not exist or windows cannot find the file. this is
from the C++ debugger. I look at the COM/OLE object viewer, and I notice on
right-click there is an instantiate object option, which returns the same
error.
I have no idea what I am doing right, and what I am doing wrong.
Can someone point me to a simple article on how to porperly export 4 C#
classes sharing an interface to COM (the most recent book tells me all I need
to do is regasm to do this). And then how to consume those objects in C++.
here is an example of the class in C#:
public interface IFoo
{
Populate1(int, int, int);
Populate2(int);
Populate3(int, int, string);
Populate4(int, string);
}
public class MyClass1 : IFoo
{
//Properties, etc
Populate1();
Populate2();
Populate3();
Populate4();
}
Same as above for the other 3 classes.
Any ideas? I am currently poring over _.NET and COM the Complete
Interoperabilit y Guide_ trying to find something... but failing to see it.
Thanks
Andrew S. Giles 2 1989
Andrew... Watch for word wrap. Never tried this. http://msdn.microsoft.com/library/de.../en-us/cpguide
/
html/cpconexposingne tframeworkcompo nentstocom.asp
You are very brave to try this. Writing a COM dll in C++ and then
calling the
methods from C# may be easier and more familiar. I mean you _can_ call
class methods using PInvoke, but does anyone want to? http://www.dotnet247.com/247referenc.../15/78221.aspx
Regards,
Jeff Can someone point me to a simple article on how to porperly export 4 C#
classes sharing an interface to COM (the most recent book tells me all I
need
to do is regasm to do this). And then how to consume those objects in
C++<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I am not exactly sure what you are driving at, but it sounds like you want
to expose a managed .exe to an unmanaged .exe through COM. I have been told
by Microsoft that this is not supported. I have gotten it to work, but there
are certain issues with interop that are misbehaving. I have an issue open
with Microsoft now to find out why. No one seems to want to answer this
question to my satisfaction.
The thing to do is to define the classes that you want to expose to COM in a
managed .dll. Then reference that from a managed executable that will
register a class factory for your creatable objects. You can then marshal
pointers to your object through the class factory. Use regasm to generate a
type library from your managed .dll and use the type library to access your
code from COM. You will also have to manually alter some registry entries to
indicate that your objects will be accessed through the .exe not the .dll.
There are a few tutorials on the web that are out there.
"Andrew S. Giles" <An**********@d iscussions.micr osoft.com> wrote in message
news:65******** *************** ***********@mic rosoft.com... OK, Ive run my head into this wall for too long. I need help.
I am developing an applicaiton in C# to present a user with a GUI to
specify a configurable list of machines that he wants to listen to the output of. Specify a filename to shove all of the data (into Excel), and start the
whole thing going. I get that done no problem. The problem comes with the
Data. The data is coming from a different application, and I am not 100% sure of what it will be written in, so COM says I is the way to get this working.
I provide the other applicaiton with an interface to my class(es) for
storing data, and when this other app uses COM to call my exposed methods, I will take care of the rest. Easy as pie. Alas, life isnt so good. I think I
am messing up somewhere in the registration of the TLB, or in the C# (this is
my first serious C# app)
My application is contained in one *.cs file, and it handles most of the
GUI stuff, and internal data storage. In another file I have defined the
classes to hold this very important data, some enums to help turn the integers
into strings, and an interface that contains the methods I want to expose to
the outside APP. All of the classes (there are 4) all inherit the same
interface (and implement all 4 methods, though 3 of them are blank returns). Everything compiles nicely into a nice executable (*.exe).
Now, I run REGASM on the executable file generating a *.tlb file as well
as telling me it registers the classes in the registry (and I can see them in the OLE/COM object viewer). Everything is looking great.
I need to test to see if the COM works though, and I do not know
when/where the real app is, so I decide to write a simple (I hope) C++ application
which will get the interface I expose, and send the data over to me. This
simple C++ app I view as the client, and the GUI in C# as the server. I hope I
am not innaccurate in those terms.
What I hope to see happening is starting up the C# app, and start it listening for data, then starting up my dummy client app, and sending data
to the C# application via the exposed COM interface.
However, I cannot instantiate the object or the pointer. I am getting errors that the file does not exist or windows cannot find the file. this
is from the C++ debugger. I look at the COM/OLE object viewer, and I notice
on right-click there is an instantiate object option, which returns the same error.
I have no idea what I am doing right, and what I am doing wrong.
Can someone point me to a simple article on how to porperly export 4 C# classes sharing an interface to COM (the most recent book tells me all I
need to do is regasm to do this). And then how to consume those objects in
C++. here is an example of the class in C#:
public interface IFoo { Populate1(int, int, int); Populate2(int); Populate3(int, int, string); Populate4(int, string); }
public class MyClass1 : IFoo { //Properties, etc Populate1(); Populate2(); Populate3(); Populate4(); }
Same as above for the other 3 classes.
Any ideas? I am currently poring over _.NET and COM the Complete Interoperabilit y Guide_ trying to find something... but failing to see it.
Thanks
Andrew S. Giles This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tank |
last post by:
I have had this post up here when i was trying to figure out how to
make leading zeros and have been able to fudge that to work. I am now
have trouble getting the loop that makes the folders to start fresh
after the .jpg section of the move images code. this will be
essential to make the whole thing work. Please help. Even if you
just write out the solution. I am beggin. I am desperate. Please
help.
<!DOCTYPE HTML PUBLIC...
|
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte buffer into the character
pointer. The code looks like the following:
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
|
by: dln |
last post by:
I'm having a rather weird problem when attempting to build my project that
maybe someone could help me out with. Basically, I have a workspace
containing two C# projects. The first project is a straight assembly and
the second is a COM interop assembly which depends on the output from first
project. Both projects contain references to three interop assemblies. I
also have the projects configured to build their output files to a common...
|
by: JM |
last post by:
Hi all,
Further to my mail yesterday, haven't received much help
and am getting slightly worried !
I am trying to add a block of cells but sadly can't get
excel VBA to exactly read my intentions.
I really wish cells H8 to H12 to be totalised but using
the following statement the formula returns "Sum(H1:H12)
|
by: Sajid |
last post by:
Hello! Experts,
I have the following piece of code in VB.NET that I want to use to
update any records in the database. I would like to use a code as well
as DataGrid to update the records. Please guide me how can I achieve
it. I know there is an Update command to to do this that but since I
am a newbie I don't know how? I'll be really grateful to those who may
help me buy modifying the following code. I am really desperately
looking for...
| |
by: |
last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It
works perfectly on my machine, but it fails on my customers' PCs that have
identical versions of Win XP (SP1) and Excel (SP1) installed.
The error is:
System.Runtime.InteropServices.COMException(0x800A03EC): Exception from
HRESULT: 0x800A03EC.
at Microsoft.Office.Interop.Excel._Worksheet.Paste(Object Destination,
Object Link)
at...
|
by: melanieab |
last post by:
Hi,
Sorry this is a long message, but I'm getting desperate (and worried). I
have a textbox (say, tb1) where the string is longer than the width of the
box. If I'm coming from the previous textbox (tb0) (by tabbing or pressing
enter or the down arrow), the text inside tb1 highlights and the cursor is at
the end of the string (so that the beginning of the string isn't visible).
If I type absolutely any key(s) other than Tab, Up, Down, or...
|
by: garyusenet |
last post by:
I have been trying to interface with my act database using .net and act
api's. I was originally using c# but it wouldn't connect to the
database. I tried VB in desperation and it is connecting!
Now i have hit another problem and i'm sure its down to the fact that
the code was written years ago, and needs a bit of modification for
..net can you take a look at these 12 lines of code and let me know how
to get it to work in .net please...
...
|
by: Wiebe Tijsma |
last post by:
Hi,
I'm running a web application application using the
Microsoft.Interop.Security.AzRoles version 1.2.0.0 in the GAC.
After an upgrade to Vista, I also have a version 2.0.0.0 in the GAC.
I seem to be absolutely unable to make the application load version 1.2.
What I've tried:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |