Click here to Skip to main content
15,116,516 members
Home / Discussions / COM
   

COM

 
QuestionAdding Workbook In Excel Pin
SB_CodeForFun6-Dec-11 21:02
MemberSB_CodeForFun6-Dec-11 21:02 
QuestionNeed Com Help - I'm a beginner Pin
jkirkerx6-Nov-11 9:48
professionaljkirkerx6-Nov-11 9:48 
AnswerRe: Need Com Help - I'm a beginner Pin
«_Superman_»6-Nov-11 16:36
professional«_Superman_»6-Nov-11 16:36 
GeneralRe: Need Com Help - I'm a beginner Pin
jkirkerx6-Nov-11 20:34
professionaljkirkerx6-Nov-11 20:34 
GeneralRe: Need Com Help - I'm a beginner Pin
jkirkerx9-Nov-11 8:36
professionaljkirkerx9-Nov-11 8:36 
QuestionHow to use unregistered tlb file Pin
SB_CodeForFun31-Oct-11 0:54
MemberSB_CodeForFun31-Oct-11 0:54 
AnswerRe: How to use unregistered tlb file Pin
DriveByCoder24-Mar-15 8:48
professionalDriveByCoder24-Mar-15 8:48 
QuestionCOM Component Late binding trouble Pin
nilarya25-Aug-11 7:28
Membernilarya25-Aug-11 7:28 
Hi All,

I have posted this message earlier on the ASP.Net forum, I did not notice there is a separate forum for Co Componenets. However I am moving the post to here, please have a look, any help would be much appreciated.

I am using a third Party Com Component in my ASP.NET application. I dont have much experience with COM Components and I think I have messed up here. Please help.

The Com component has a method which looks like following in the ILDASM:

.method public hidebysig newslot specialname virtual
instance class [stdole]stdole.IPicture
marshal( interface )
get_Preview([in] float64 rWorldMinX,
[in] float64 rWorldMinY,
[in] float64 rWorldMaxX,
[in] float64 rWorldMaxY,
[in] int32 dwPicWidth,
[in] int32 dwPicHeight,
[in] int32 PicType) runtime managed internalcall

In my code behind, I am using


C#
object ComObjLateBound;
Type ComObjType;
ComObjType= Type.GetTypeFromCLSID(new Guid("{89251546-3F1C-430D-BA77-F86572FA4EF6}"));
ComObjLateBound= Activator.CreateInstance(ComObjType);
 
//getting the values from the properties. The properties are in the Com Component 
double viewMaxX = (double)ComObjType.InvokeMember("ViewMaxX", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
double viewMaxX = (double)ComObjType.InvokeMember("ViewMaxY", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
double viewMaxX = (double)ComObjType.InvokeMember("ViewMinX", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
double viewMaxX = (double)ComObjType.InvokeMember("ViewMinY", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
 
//geting the image height and width from a local file
int imagewidth, imageheight, pictype;
imagewidth = 1280; imageheight = 800; pictype = 1;
 
object[] previewDetails = new object[7];
previewDetails[0] = viewMinX;
 
previewDetails[1] = viewMinY;
 
previewDetails[2] = viewMaxX;
 
previewDetails[3] = viewMaxY;
 
previewDetails[4] = imagewidth;
 
previewDetails[5] = imageheight;
 
previewDetails[6] = pictype;
 
 
IPicture picture = (IPicture)ComObjType.InvokeMember("get_Preview", BindingFlags.Default | BindingFlags.InvokeMethod, null, ComObjLateBound, previewDetails);



this fails with a COM Exception like

{"Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))"}

with an ErrorCode of -2147352570 if that means something.

Now this is strange, because the exception type and Error Code remains exactly the same if I use any name instead of "get_Preview".

the COM component also has a Preview Property which looks the following in ILDASM:

.property class [stdole]stdole.IPicture Preview(float64,
float64,
float64,
float64,
int32,
int32,
int32)
I have also tried to use this property to get the IPicture value like:

C#
IPicture picture = (IPicture)ComObjType.InvokeMember("Preview", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, previewDetails);


But it also falis with a message that Exception has been thrown by the target of an invocation.

Please note, I am not able to use early binding on this component as it gives me an error message -

Unable to cast COM object of type '<>' to interface type '<>'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{}' failed due to the following error: No such interface supported.

I think I am doing something wrong here. Can you please point out what it is?

Thanks in advance.

AnswerRe: COM Component Late binding trouble Pin
tom-englert21-Sep-11 2:20
Membertom-englert21-Sep-11 2:20 
GeneralRe: COM Component Late binding trouble Pin
nilarya7-Oct-11 0:27
Membernilarya7-Oct-11 0:27 
GeneralRe: COM Component Late binding trouble Pin
tom-englert7-Oct-11 4:59
Membertom-englert7-Oct-11 4:59 
GeneralRe: COM Component Late binding trouble Pin
nilarya7-Oct-11 23:46
Membernilarya7-Oct-11 23:46 
GeneralRe: COM Component Late binding trouble Pin
nilarya7-Oct-11 23:57
Membernilarya7-Oct-11 23:57 
GeneralRe: COM Component Late binding trouble Pin
nilarya24-Oct-11 0:27
Membernilarya24-Oct-11 0:27 
GeneralRe: COM Component Late binding trouble Pin
tom-englert7-Nov-11 7:23
Membertom-englert7-Nov-11 7:23 
AnswerRe: COM Component Late binding trouble Pin
Vi25-Oct-11 1:39
MemberVi25-Oct-11 1:39 
QuestionUnable to register 64 bit COM Server Pin
sandeepkavade17-Aug-11 3:07
Membersandeepkavade17-Aug-11 3:07 
AnswerRe: Unable to register 64 bit COM Server Pin
Shameel17-Aug-11 3:32
professionalShameel17-Aug-11 3:32 
AnswerRe: Unable to register 64 bit COM Server Pin
«_Superman_»19-Aug-11 5:18
professional«_Superman_»19-Aug-11 5:18 
QuestionRegarding SheetCalculate event in Excel API Pin
gtag20-Jun-11 11:02
Membergtag20-Jun-11 11:02 
AnswerRe: Regarding SheetCalculate event in Excel API Pin
«_Superman_»13-Jul-11 8:04
professional«_Superman_»13-Jul-11 8:04 
AnswerI need help...(context menu shell extension) [modified] Pin
T800G5-Jun-11 5:53
MemberT800G5-Jun-11 5:53 
Questionhow do i find all "src" attributes from frame object of html document? Pin
yogish29313-May-11 4:20
Memberyogish29313-May-11 4:20 
AnswerRe: how do i find all "src" attributes from frame object of html document? Pin
«_Superman_»21-Jun-11 20:43
professional«_Superman_»21-Jun-11 20:43 
QuestionHow to create an OLE control in EXCEL sheet? Pin
whiteclouds28-Apr-11 0:46
Memberwhiteclouds28-Apr-11 0:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.