|
Sohail,
Not yet solved.
Let me explain the current situation. I created a sample C# class library project. The code is listed below:
COMServer:
using System;
using System.Runtime.InteropServices;
namespace MyComServer
{
public delegate void MyComEventHandler();
// Step 1: Defines an event sink interface to be implemented by the COM sink.
<Guid({16FA6CC7-E2B9-4326-9D4F-ADBAADA6627D})]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IMyComEvents
{ [DispId(1)]
void myComEvent();
}
// Step 2: Connects the event sink interface to a class by passing the namespace and event sink interface
[ComSourceInterfaces(typeof(MyComServer.IMyComEvents))]
public class MyComCls
{
public event MyComEventHandler myComEvent;
public MyComCls()
{}
public void raiseMyComEvent()
{
this.myComEvent();
}
}
}
Then the DLL file named MyComServer is registered using the following command
regasm MyComServer.dll /tlb:MyComServer.tlb
then after giving a Strong Name [sn -k MyComServer.snk]
the DLL file is registered into the global assembly using the command
gacutil -i MyComServer.dll
COMClient:
For the client application I used VC++ 6 MFC wizard[exe] and a simple dialog object.
I imported the MyComServer.tlb into stdafx.h file and all supporting header files.
Also done event sinking. After all those process i executed the MFC application. Then i encountered COM Error: 0x80040154 Class Not Registered.
Also is there any other option to invoke the events written in the class library?
Cathrin
|
|
|
|
|
Are you missing [ComVisible(true)] attribute for your COM coclass?
-- modified at 7:16 Monday 22nd October, 2007
What is your VC++ client code for creating the object?
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Yes, [ComVisible(true)] attribute in .NET Class Library (AssemblyInfo.cs).
|
|
|
|
|
Catharin wrote: Yes, [ComVisible(true)] attribute in .NET Class Library (AssemblyInfo.cs)
So COMVisible(true) is present for the coclass you are instantiating from your VC++ client?
Can you tell me which part of your code fails with the HRESULT value you mentioned?
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I am writing a plug-in which have a function call WORD and then get text from WORD. So, I must get Close event of WORD so that I could get the text from WORD. I created a CWordSinkEvent class to get the event. When WORD is closed, function OnWordClose() is called. But I was not allowed to call this function from my plug-in because this function is : afx_msg void OnWordClose(). I want my plug-in wait until it receive the Close event of WORD and get the text from WORD. Please help me with any solution as well. Thank you so much.
|
|
|
|
|
Hi!
I've this problem.I've to do a in process COM server in C++;the server has to send in real time as fast as possible a vector of six elements produced by a stand alone application (written in C++) to a MATLAB client. MATLAB client can't read the new value of vector untill the application does not write new one.
Can you suggest me a possible solution?
Thanks.
DanyCode
|
|
|
|
|
How to call events written in C#.NET within VC++ 6.0?
please post a reply as soon as possible.
|
|
|
|
|
|
Thank you for a fast response
|
|
|
|
|
Hello all...
I have looked high and low online for an answer and nothing comes up.
I am using the Windows Media Player control in my app (language: C++ via MFC 4.2). What i need is to get access to the IWMPVideoCtrl interface so i can have the ablilty to alter the "stretchToFit" and "maintainAspectRatio" properties. Is there a trick to doing this? I do have a reference to the IWMPPlayer interface, but, there is no method where i can pass in and get a reference to the IWMPVideoCtrl interface.
Any ideas?
Thanks...
-andy.
|
|
|
|
|
After a bit of searching, i found the interface which supports setting "stretchToFit"... This property also forces "maintainAspectRatio", so this is the answer. I am posting this here incase anyone else runs into this problem.
http://msdn2.microsoft.com/en-us/library/bb249119.aspx[^]
When you have an IWMPPlayer interface created, you can call IWMPPlayer::QueryInterface() on an IWMPPlayer2 interface. This will add in the "stretchToFit" properties laying within the IWMPPlayer2 interface.
-andy.
|
|
|
|
|
I have seen the COM from scratch...but still not getting.........
I just want to create simple COM component.........
shailesh
|
|
|
|
|
Unfortunately it is difficult for a COM component to be 'simple', however, this book [^]. gives a good explanation of a basic COM component.
Anyway, you can easily create a COM component project using the MFC or the ATL wizard.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Have you read my Intro to COM[^] articles? Part 2 shows how to write a COM server and shows how to call it.
|
|
|
|
|
Can any one help me i am new commer to com . can we use com controls
in .NET
vimal
|
|
|
|
|
Yes, have a look at [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
As I am new to COM I still unable to get the Life cycle of COM program...or flow of program...
so I want the step by step program or step by step code with descripton to generate new COM component...
shailesh
|
|
|
|
|
There's the Jeff Glatt's very good article series here at CP, follow the link to the first article.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi group,
I have written a COM Addin for Excel so I did add few lines to add a custom menu in Excel. It worked fine but as I was playing with the code I passed a parameter which has made the menus permenant instead of temporary. Now, when you run the Excel the menu comes. How can I remove it or reset the Excel menu bar?
Your help is appreciated greatly.
Regards,
Amit
|
|
|
|
|
Hi group again,
It is solved by using the "Detect and Repait" under Help menu.
Amit
|
|
|
|
|
Hi,
I'm fairly new to COM, despite being late in the game, so to speak.
I've got a COM object that upon unregistering, is removing keys from another COM object.
We've tracked the problem to an offending 'import'.
COM object A.idl imports B.idl, which in turn imports C.idl.
On registration / unregistration, COM object A registers / unregisters (the guids for) COM object C.
Unfortunately, the import calls are needed as both A and B use types defined in C.
Trying to include the header files for B and C are presenting problems due to redefinitions of types in winnt.h.
If I remove the offending import call in A.idl the problem is resolved, but I must remove one of the methods from the interface in order to build the object.
I didn't design this software, but I am faced with having to fix it.
cheekymuppet
|
|
|
|
|
Hi all
I need to OCR a picture box image, the image of the picture box is created by setting bitmap pixels:
Bitmap ^ bmpPenImage = gcnew Bitmap(siPenImageWidth, siPenImageHeight);
pictureBox1->Image::set(bmpPenImage);
bmpPenImage->Save(L"savedImage.bmp",System::Drawing::Imaging::ImageFormat::MemoryBmp);
MODI::Document ^ aDocument = gcnew MODI::Document();
aDocument->Create(L"savedImage.bmp");
aDocument->OCR(MODI::MiLANGUAGES::miLANG_ENGLISH, true, true);
MODI::Image ^ anImage = (MODI::Image ^)aDocument->Images[0];
MODI::Layout ^ aLayout = anImage->Layout;
MODI::Word ^ aWord = (MODI::Word ^)aLayout->Words[0];
label1->Text = aWord->Text;
aDocument->Close(false);
As you can see i'm using a lame approach by saving the image and then reading it again in the lack of something else But this approach gives me the following runtime error:
COMException: OCR Running error
I would appreciate it if someone could help me with maybe a different approach? I can't find much info about document imaging 12. in Visual C++ 2005.
Thanks alot
|
|
|
|
|
Found a solution myself after much experimenting...
setting the image to a pictureBox in some way bounds that image file so that it cannot be used by OCR... if you move the statement "pictureBox1->Image::set(bmpPenImage); to the end, that is after aDocument->Close(false); it works.
OCR also appears to be sensitive to the image size, i'm still experimenting but it seems to like larger scaled images, you sometimes get the same "OCR running error" setting pixels to blue, this is all wierd but if someone can still clear this issue i'll be thankful.
|
|
|
|
|
If I create an instance of an Out of Process Server, what part of Windows actually calls CreateProcess() to launch the executable?
Is it one of the services, or something deeper?
|
|
|
|
|
Is the COM Service Control Manager see [^] for details and references.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|