|
I have two assemblies which both contain a definition for a specific interface, unfortunately these definitions differ in that some of the function signatures require different type like:
SomeFunction(IntPtr param1, int param2);
and
SomeFunction(MyClass param1, MyEnum param2);
(Obviously not the real function and class names)
When I try to bind to the interface from the other assembly I get an InvalidCastException even though they are both defined with the same GUID.
Is there any way I can get this to work without changing the signatures as this causes a lot of issues in the rest of the project (Both parts not mine BTW).
Thanks.
|
|
|
|
|
Have you tried casting to the required type?
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
So you have an interface that looks like this:
public interface IMyFunctions
{
SomeFunction(IntPtr param1, int param2);
SomeFunction(MyClass param1, MyEnum param2);
} which is defined in assembly Interfaces.dll?
In some other assembly you have a class that looks like
public class SomeClass : IMyFunction
{
SomeFunction(IntPtr param1, int param2) { ... };
SomeFunction(MyClass param1, MyEnum param2) { ... };
} Assuming that the above is reasonably correct to your implementation, you get an InvalidCastException when you try to do what?
What do you mean "they are defined with the same GUID"? There are no GUIDs that you can set that have any kind of impact on the compiler and runtime behavior.
Have you stepped through the code with a debugger attached to see where the exception is actually ocurring? That should give you a better idea of what is going wrong.
|
|
|
|
|
I should have been more clear. The interface is IShellFolder, it is defined in both assemblies as a ComImport
[ComImport, Guid("000214E6-0000-0000-C000-000000000046"),<br />
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
The problem is the the signatures are different, for example:
<br />
int BindToObject(IntPtr pidl, [In] IntPtr pbc, [In] ref Guid riid, [Out] out IntPtr ppv);<br />
and
<br />
int BindToObject(IntPtr pidl, [In] IntPtr pbc, [In] ref Guid riid, [Out, MarshalAs(UnmanagedType.Interface)] out IShellFolder ppv);<br />
When I call IShellFolder.BindToObject on from one assembly to the other I get a valid IntPtr but when I cast it using Marshal.GetObjectForIUnknown I get an error saying "Specified cast is not valid"
|
|
|
|
|
Hi all,
I would like to have a control that can be binded either to *.Jpg for a picture or *.mpeg for a video content.
Can you please help me get which control i have to use to accopmlish this task?
Is there any control on the default microsoft Toolbox?
Thanks very much.
-- modified at 9:39 Wednesday 15th August, 2007
|
|
|
|
|
You can use the WebBrowser control which can display pictures natively or embed WMP in the HTML to play video.
|
|
|
|
|
Thank you very much for your time.
Sorry can i get this control on the default C sharp or Asp.net Developent toolbox?
If not where can i find it?How would i include it in to my page?
I am using C sharp and Asp.net for reporting application.
Thanks for you time.
|
|
|
|
|
The WebBrowser control is for the Windows Forms toolkit (e.g. C# desktop app development). I don't know ASP.NET well enough to tell you whether there's such a control. Probably not. My guess is you could simply have some logic that created an <img> tag for images, and otherwise used Flash or Windows Media Player for video.
|
|
|
|
|
Thanks very much once again,
How will i get the Window Media player in to the toolbox?
sorry i havent used it before?
Can you please get me the steps in getting the media player on to My ASP page?
Thanks
|
|
|
|
|
This question is better posed in the ASP.NET message board.
Phil
|
|
|
|
|
|
how to save , edit,querry a database using C# toolbar
|
|
|
|
|
What's C# toolbar? Is this something you designed?
|
|
|
|
|
hi all
how i can convert the language (English to Arabic) When i Leave the TextBox1 to TextBox2 The Convert just in text language as
TextBox1 is write in English language and the TextBox2 is Write by Arabic Language
thanks for all body hellp me
Thaer
|
|
|
|
|
First you will need to catch textbox2 enter event. In that event you can change input language. Then set input language using InputLanguage Class
|
|
|
|
|
thanks Mr Giorgi Dalakishvili
but your answer is not Complete my Quesion
Pleas if you have Code To ny Quesion Give me it
thanks Mr
Thaer
|
|
|
|
|
First, you have asked this question before. Second, this forum is for people who are having issues with existing code. Asking someone to just hand over the code so you don't have to work on it is considered RUDE.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
No one is going to give you complete code here. I gave you directions and you can explore them. If you are stuck at a specific point please say so and I'll be happy to help you
|
|
|
|
|
do you want to enter english in tb1 and enter arabic in tb2, or enter english in tb1 and have it translated into arabic and displayed in tb2? The existing answer will let you do the former, the latter will require buying 3rd party translation software. I have no recommendation for this.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
Hi,
I have the following code to upload one file.
private void cmdUpload_Click(object sender, System.EventArgs e)
{
if (( File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
{
//determine file name
string sFileName = System.IO.Path.GetFileName(File1.PostedFile.FileName);
try
{
if (File1.PostedFile.ContentLength <= lMaxFileSize)
{
//Save File on disk
File1.PostedFile.SaveAs(sFileDir + sFileName);
lblMessage.Visible=true;
lblMessage.Text="File: " + sFileDir + sFileName + " Uploaded Successfully";
}
else //reject file
{
lblMessage.Visible=true;
lblMessage.Text="File Size if Over the Limit of " + lMaxFileSize ;
}
}
catch(Exception)//in case of an error
{
lblMessage.Visible = true;
lblMessage.Text="An Error Occured. Please Try Again!";
DeleteFile(sFileDir + sFileName);
}
}
}
I want to upload two files intead of one.
Please help.
|
|
|
|
|
I have a mulitline text file that has repetitive info in the first 29 characters.
My program will strip the extra garbage off from each line and append it to the previous line.
It also will change the color on specific lines of text, at a specific position, and it opens into a RichTextBox.
I would like to speed this up somehow. Depending on the size of the file it takes a long time. I want to be able to apply the formatting etc while the file is in a buffer I guess, and then display to the RichTextBox.
Thanks,
|
|
|
|
|
Hi
well I have an XML file and an XSL file to transform that. I want to show the XML file in the webbrowser control having the transformation on using the XSL file. As most of u must be knowing that we need to add a statement such as the one given in bold after the <xml> tag.
<?xml version="1.0" encoding="utf-8"?>
<b><?xml-stylesheet type="text/xsl" href="c:\xmlDefaultStyleSheet2.xsl"?></b>
Is there some way so that I can just write that portion to my xml file and show it in the browser (modifying the file) so that I dont have to write a new xml file altogether?
Thanks in advance
Rocky
|
|
|
|
|
Rocky71 wrote: Is there some way
No. But there is a way you can keep from re-writing the xml source file, by performing the transformation yourself and load the results in the browser.
|
|
|
|
|
OK so can u give me an example for that...
|
|
|
|
|