....and you get safe array type mismatch exceptions from the marshaller.
I have a C++ COM object (thank God I could find the source) that was
declared properly in the IDL for [out, retval] and requiring a VARIANT*,
everytime I tried to use this object from C# the marshaller would throw up
marshalling the return value. Now, I should mention that this COM object
works great in when used by C++ code which has to marshall the data as well.
I googled my rear off learning all kinds of interesting stuff which I hope
I'll never have to use in real life (editing CIL files the recompiling them
in order to trick the runtime marshaller), none of it worked.
I had, or course, already checked to see how the SAFEARRAYs were passed back
and, being an old time COM developer, I didn't notice anything unusual.
VT_ARRAY were declared with the appropriate type info. Bounds were set
properly, et cetera.
I checked for VTDISPATCH, I tried important the type lib with /sysarray, all
to no effect.
Basically I tried everything I could google.
Then I noticed that the memory for the array was allocated in a relatively
old fashioned manner in the C++ COM object. It didn't use SafeArrayCreate
(sp?) it did a system allocation like you used to always do in the earlier
days of automation and then setup the array (properly) with elements and
bounds et al.
Changing the data allocation to use SafeArrayCreate solved the C#
marshalling issue for me entirely.
I just wanted to put this out there so that in 3 years when I run into this
again and forget how I solved the problem I can google myself ;).
WTH
--
"I will always remain a fan of Liverpool Football Club. I'll come here again
as a friend and a fan and I will cheer the boys on." - Gérard Houllier 0 1241 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeff Wagner |
last post by:
I am in the process of learning Python (obsessively so). I've been through a few tutorials and read
a Python book that was lent to me. I am now trying to put what I've learned to use by rewriting that
Numerology program I wrote years ago in VB.
There are times I am totally stuck (for instance, I just had an idea to put the numerical values of
the alphabet and months of the year in a dictionary located in a function. Then, I can import the...
|
by: Thilanga |
last post by:
Hi,
I want to access a VARIANT array returned by a method in VC++, that is
supposed to be a long array.
Can anybody suggest me a way of access this array and get the values
in it.
Following is a sample code:
|
by: xtra |
last post by:
Hi Folk
I have about 1000 procedures in my project. Many, many of them are along
the lines of
function myfuntion () as boolean
on error goto er
'-
Dim Dbs as dao.database
Dim Rst as dao.recordset
|
by: Gabe Covert |
last post by:
I'm a new C# developer, and am developing an application which will utilize
a COM library from a third party. I have two following SDK calls from the
3rd-party SDK which I can't get to work under C#:
SDK declaration:
VARIANT_BOOL ReadMemory(unsigned char* Data, long DataSize);
tlbimp result:
|
by: mseeger |
last post by:
My concrete problem is this (it is a bit special, but there may be other
instances of it):
I'd like to create a class for vectors (say: Vector), exporting math. methods, say v.foo(...).
I'd like to implement 'operator()' s.t. I can treat parts of a vector in the same
way as a normal vector: if v.foo(...) works, so should v(rng).foo(...), where
rng is a range object. This should work even if 'foo' is a non-const method.
I do this by...
| |
by: MikalE |
last post by:
I’m using a third-party ActicveX component that has the following description for one of its events:
They mean by this that LocationType is an array of VARIANTS (containing enumeration)
When the OnAlarm Event is raised I have problems getting the 3 last values from it.
I have ported my application from VB.Net to C# and this is the only problem I can’t figure out how to solve in doing so.
In VB.Net it’s very easy to access these...
|
by: CuTe_Engineer |
last post by:
hii,
i have cs assignment i tried to solve it but i still have many
errors , plzz help mee :"< it`s not cheating becuz i`ve tried & wrote
the prog. i just wanna you to show me my mistakes
#these are the operations
+ = ,
- = ,
* = ,
1/ = only if 0 not in .
|
by: Bjoern |
last post by:
Hi
I have a COM object which fires an event where I have to pass an array
of SHORTs as a parameter to the listening object. The array of SHORTs
is encapsulated in a the CComSafeArray-class and passed as a VARIANT*
in MIDL (since MIDL doesn't support SAFEARRAYs in events).
In C# (.NET 1.0) the MIDL VARIANT* data-type is registered as "ref
object" in the event-handler (delegate). How do I convert this "ref
object" to a short array?
|
by: Coxmg |
last post by:
Here is the code, ACCESS 2007:
Hello, I have a dialog box that opens on a form that lets the user browse files. I simply want to limit it to Folders, how can I do that? Need ASAP. Thanks. ACCESS 2007.
Here is my code, how do I prevent it from showing files? I want Folders only.
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Declare a variable to contain the path
'of each selected item. Even...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: 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...
| |