microsoft.public.dotnet.framework.interop Archive - November 2001
Post a message to this list
Messages
Page: 1
How i can i call c++ exported classes in c# (3 replies)
microsoft.public.dotnet.framework.interop
Hi, We have lot of code written in C which are in dll. All the classes are exported from the DLL. Can i use this classes in c#. What are the steps i need to do to use this. Will there be a big performance hit ?? Any info or links which has this will be a great help. Thanks a lot Prasad
MarshalAs for SafeArrays (5 replies)
microsoft.public.dotnet.framework.interop
I'm trying to pass a safearray of Bstrs into a .NET procedure. I followed the examples given in http://msdn.microsoft.com/library/default.asp?url /library/en us/cpguidnf/ht ml/cpconarraytypes.asp. My procedure is specified as follows: Public Sub PassArray( MarshalAs(UnmanagedType.SafeArray, SafeArraySubType VT BSTR) ByRef TheArray() As String) The problem is the second attribute argument for the s...
Error 80070057;CS2011 (2 replies)
microsoft.public.dotnet.framework.interop
I'm receiving the following when error calling my COM web service client in ASP on IIS 5. However, everything works fine in VB6. This machine does not have Visual Studio .NET installed but I also receive it when I port it to another machine with .NET installed. Everything works fine on the development machine that also contains the web service. Microsoft.VisualBasic error '80070057' Unable to gene...
Referencing MSHTML (3 replies)
microsoft.public.dotnet.framework.interop
Hello I've added a reference to MSHTML to my dot net project, but when I attempt to use an instance of MSHTML.HTMLDocument, I get a System.NullReferenceException. I'm guessing the HTMLDocument object is not propperly initialized, but I don't know what I'm missing. Any ideas? Adam Dim d As New MSHTML.HTMLDocument() ' these two lines work d.createElement("a") d.createDocumentFragment() ' either of t...
Use com interop with asp (2 replies)
microsoft.public.dotnet.framework.interop
I have a webservice that I need to use in an asp page. I wrote a class that is exposed through com interop, and it work in a regular windows program if I call creatobject("myproject.myclass"), but I do this from asp using server.creatobject("myproject.myclass"), it fails with "Error: 2146233054 No server registered or could not load class for CLSID {0F16D257 6AAF 3628 94A5 7D1549C37EEF}." Thanks R...
Interop question (3 replies)
microsoft.public.dotnet.framework.interop
I'm trying to call the reverse string function in the C runtime from C#. I have attempted the following but I keep getting an exception when calling it. Here's the interop for the function (I've tried with and without the ref keyword): [System.Runtime.InteropServices.DllImport("msvcrt.dll")] static extern String wcsrev(ref String sString); and callinging it like: sReversedString wcsrev(ref sString...
Using OLESaveToStream (and IStream in general)? (7 replies)
microsoft.public.dotnet.framework.interop
Has anyone done this successfullly? We have legacy COM components that implement IPersistStream to save themselves. In old code, we'd do CreateStreamOnHGLOBAL to get a memory stream, OleSaveToStream to write our component to that block of memory, then read the bytes out for our own purposes. (as well as, generally, letting the objects be serialisable for clipboard stuff, etc, etc). In .net, there'...
Passing a COM object to another COM object (2 replies)
microsoft.public.dotnet.framework.interop
Does anyone know how to pass a reference of one COM object into a method of another COM object? My C COM objects were wrapped by the .NET system and now it doesn't like interfacing the two COM objects. Any ideas on how to do this in VB or C# (for an ASP app) would be greatly appreciated. Thanks,
Marshal.PtrToStructure question... (3 replies)
microsoft.public.dotnet.framework.interop
After much trial and error I have given up on trying to recreate the NCCALCSIZE PARAMS structure and have gone with a simpler plan instead. The question that I have is if I use the Marshal.PtrToStructure method, does it return me an Structure the represents the Pointer or does it create a new Structure based on the data that the pointer points to. Here is an example: ******************************...
Accessing a dynamic array in an IDL from .net? (2 replies)
microsoft.public.dotnet.framework.interop
Hi The Dot Net RCW does not seem to be able to properly translate an IDL description of a dynamic array of structures. After I added a reference to the COM implementation of the IDL, my C# app read the dynamic array as one structure. Is there a fix or a different IDL declaration that would be compatible with Dot Net. Thanks HRESULT Open( [in] VIF IF, [in] const long Count, [in, size is(Count)] VWe...
COM and managed app - what about "Release"? (2 replies)
microsoft.public.dotnet.framework.interop
Hi We are writing a managed component that needs to run as a part of Visual Studio 7.0. At some point we assign the VS automation oobject (EnvDTE) to our component and by doing this an "AddRef" is done. How can we call "Release" from managed code? Should we do this. MVH Bo BrogÄrd Lund
Marshalling struct with string from C# to c (6 replies)
microsoft.public.dotnet.framework.interop
Hi, I am trying to call a c function from c#. One of the arguments is a structure c/c syntax: struct MyStryct { char* MyString; short LengthOfMyString; }; MyString is an empty buffer (preferebly with 0 values) and LengthOfMyString is the size of this buffer. When callin functions with arguments like this, I have succeeded by using a preallocated StringBuilder. However, I am not allowed to do this ...
How to Use IntPtr and Marshal.QueryInterface(...)? (4 replies)
microsoft.public.dotnet.framework.interop
In VC , calling QueryInterface and you get an Interface, you can then call the function of the interface. e,g. code from wallall (reusing MSHTML) sample: HRESULT CApp::LoadURLFromFile() { HRESULT hr; ......... LPPERSISTFILE pPF; // MSHTML supports file persistence for ordinary files. if ( SUCCEEDED(hr m pMSHTML QueryInterface(IID IPersistFile, (LPVOID*) &pPF))) { ....... hr pPF Load(wszURL, 0); pP...
Memory Device Contexts / BitBlt ? (6 replies)
microsoft.public.dotnet.framework.interop
Hi, I'm a C programmer just getting started C# and the .NET Framework. Is there no managed method of having a "memory" Graphics object to do fast BitBlt ing to a Windows Form control during its OnPaint() event to maximum drawing performance? Thanks, Tony
How do I "StructLayout" a char? (2 replies)
microsoft.public.dotnet.framework.interop
I'm trying to call some DLLs, but I need to pass a char[40] on the stack to a function. How is this done? for example I want to accomplish the following code: [DllImport("SomeCrazyDLL", EntryPoint "MyFunction")] static extern MyFunction(int test, char[50] theString); Chris
How to marshal types like INTERNET_DEFAULT_FTP_PORT in c# from wininet.dll (2 replies)
microsoft.public.dotnet.framework.interop
Hello everyone, maybe this problem concerns a lot of people, and i am not hesitating to ask for it: In wininet.dll or wininet.h there are define statements like #define INTERNET DEFAULT FTP PORT 21 or #define INTERNET REQFLAG CACHE WRITE DISABLED 0x00000040 how to use these define statements in C# ??? Problem is: Some methods are imported by dllimport Attributes . Originally the methods require th...
SafeArray problem (6 replies)
microsoft.public.dotnet.framework.interop
I have a COM object with a method in its interface which produces a SAFEARRAY as its return value, e.g... [id(42)]HRESULT RetrieveArray([out, retval, satype(byte)] SAFEARRAY** ppArray); What I have found, after much debugging, is that .NET does not understand SAFEARRAYs which have been created using SafeArrayCreateVector(Ex). When I import this interface into .NET it correctly translates ppArray i...
API calls using struct c#, (Map Drive) how to? (4 replies)
microsoft.public.dotnet.framework.interop
Hi! I have been browsing for hours trying to find the answer for my question, without any luck so help would be very appreciated... Question: I am trying to Map a network drive using DWORD WNetAddConnection3( HWND hwndOwner, LPNETRESOURCE lpNetResource, LPTSTR lpPassword, LPTSTR lpUserName, DWORD dwFlags ); in the mpr.dll. I have declared the function as follows: [DllImport("mpr.dll")] public stat...
How do I marshal array of strings passed by ref? (6 replies)
microsoft.public.dotnet.framework.interop
Hello, How do I marshal array of strings passed by ref? Most of the samples I've seen deal with marshalling a single string, or an array of other primitive types (int, etc...). What is happening is clearly described in the documentation: " if you call an unmanaged function, passing a byref array argument, platform invoke copies all its elements to an unmanaged buffer. However, when copied back, pl...
Using unmanaged DLL Function from C# / (6 replies)
microsoft.public.dotnet.framework.interop
Hi, i want to use the following function provided by a unmanaged DLL in C#. Unmanaged C Declaration : int GetData(unsigned char * pBufer,int iBufferSize,unsigned char bDataFormat); How looks the [DllImport] Declaration in C# for this function ? Thanks Gregor
Marshalling BUG? PInvoke sample by Sonja Keserovic (MSFT) (2 replies)
microsoft.public.dotnet.framework.interop
Hello, I am using the PInvoke sample provided by Sonja Keserovic (MSFT). I modified the call to: // without [In, Out] string array will not be copied out // int TestArrayOfStrings(char** ppStrArray, int size) [ DllImport( "..\\LIB\\PinvokeLib.dll" )] public static extern int TestArrayOfStrings( [In, Out] String[] stringArray, int size ); // *************** string array ByVal **********************...
AviCap32.dll .... (3 replies)
microsoft.public.dotnet.framework.interop
Hello .NET fellows, I trying to port aviCap32.dll to .NET and got 2 problems. problem 1 If I make an dllImport: DllImport("avicap32.dll", EntryPoint: "capGetDriverDescriptionA", SetLastError: True, CharSet: CharSet.Unicode, ExactSpelling: True, CallingConvention: CallingConvention.StdCall) Public Function capGetDriverDescription(ByVal dwDriverIndex As Long, ByVal lpszName As String, ByVal cbName A...
Ad
Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification