473,808 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error while implementing interface

LGS
These three lines work fine in c++.

hr = CoInitialize(NU LL);
hr = CoCreateInstanc e(CLSID_WiaDevM gr, NULL, CLSCTX_ALL, IID_IWiaDevMgr,
(LPVOID *)&iDM);
hr = iDM->SelectDeviceDl g(NULL, 0, 0, NULL, &iRoot);

However, attempts to implement this in c# are proving difficult. Since
there is no idl or tlb for Windows Image Acquisition (WIA), I'm rolling my
own. Clearly I've done it incorrectly, but I can't spot it. I'm not looking
for someone to write the interface for me. Just for any general interop
tips, troubleshooting , or references.

I've included some code snippets in case something jumps out at someone.
The interfaces here are in wia.h in the platform sdk.

The error is that calls to SelectDeviceDlg keep returning
System.NullRefe renceException:

Guid g = new Guid("a1f4e726-8cf1-11d1-bf92-0060081ed811");

IWiaDevMgr iw = (IWiaDevMgr) Activator.Creat eInstance(
Type.GetTypeFro mCLSID( g, true ) );
IWiaItem pRoot;
iw.SelectDevice Dlg(0, 1, 0, 0, out pRoot);

The (partial) interface listings are below. I've tried everything I can
think of. I've changed the parameter types to IntPtr, int, I've tried
MarshalAs, ref, nothing seems to work.
[Guid("4db1ad10-3391-11d2-9a33-00c04fa36145"),
InterfaceType(C omInterfaceType .InterfaceIsIUn known)]
public interface IWiaItem
{
etc
[ComVisible(true ), ComImport,
Guid("5eb2502a-8cf1-11d1-bf92-0060081ed811"),
InterfaceType(C omInterfaceType .InterfaceIsIUn known)]
public interface IWiaDevMgr
{
[PreserveSig]
int EnumDeviceInfo(
long lFlag,
out IntPtr ppIEnum); // IEnumWIA_DEV_IN FO **

[PreserveSig]
int CreateDevice(
[MarshalAs(Unman agedType.BStr)] string bstrDeviceID,
IntPtr ppWiaItemRoot); // IWiaItem **

//[PreserveSig]
int SelectDeviceDlg (
/* [in] */ int hwndParent,
/* [in] */ long lDeviceType,
/* [in] */ long lFlags,
/* [out][in] */ int pbstrDeviceID, // Bstr *
[Out] out IWiaItem i3);
etc
Nov 16 '05 #1
0 2509

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2762
by: Martyn Lawson | last post by:
Hi, I am currently working as an Analyst on a .NET Web Project using ASP.NET and C#.NET. I have a couple of, at least what should be, quick questions: 1. My understanding of UML says that the Controller classe of a Sequence Diagram should be implemented as a private class within a component. However, my Programmer has said that since the ASP code lives outside the
67
4290
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. Unfortunately these ad hominem rhetorts are frequently introduced into purely technical discussions on the feasibility of supporting such functionality in C++. That usually serves to divert the discussion from the technical subject to a discussion of the...
9
5298
by: Tyler | last post by:
I am attempting to extend a legacy VB6 application by making it use a .NET component written in C# exposed through COM interop. Everything appeared to be going well (VB application creates the .NET component instead of the legacy VB6 component and invokes some methods successfully) until I hit a snag. For one method that is being invoked by the VB6 application, the method takes 2 parameters (string values) and a custom interface. ...
5
1673
by: Colin McGuire | last post by:
Hi all, when I write the class below Private Class employee End Class and then add the line "Implements IVF" which is an interface I have written, the IDE modifies my code to display
7
2098
by: Scott M. | last post by:
In a typical class, do I need to indicate that it implements the IDisposable interface and then create a Dispose method that implements the Dispose required by the IDisposable interface or can I just make a Sub Dispose() and the CLR will know that this is the Dispose method to call when the object falls out of scope? Thanks.
2
6793
by: larzeb | last post by:
I receive the following error from the compiler: ScheduledInfo' must implement 'Property AddrLine1() As String' for interface 'ICASSBatch'. Implementing property must have matching 'ReadOnly'/'WriteOnly' specifiers. The interface: Public Interface ICASSBatch Property AddrLine1() As String Property BarCode() As String
1
1132
by: Gomathi | last post by:
hi all, How to implement an interface in ASP.Net?. Consider my interface name is IExample. Then whatz mean by IExample ie = (IExample)obj1 Kindly let me know about this implementing interface in detail. Thanks in advance.
3
1669
by: David Veeneman | last post by:
I'm new to VB.NET, and I am translating an object model from C# to VB.NET, and I have come across an odd problem implementing an interface. The interface is a custom interface, IDrillDown, which declares one read-only property with the following VB.NET signature: Public ReadOnly Property ActiveText() As String I have declared the interface in the class declaration, like this:
6
8523
by: Raj Wall | last post by:
Hi, I am trying to implement the IEqualityComparer interface for a struct so I can use it as the Key for a Dictionary. My struct declaration has: public struct Ring : IEqualityComparer { .... } and I am trying to implement the Equals and GetHashCode methods.
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10628
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10373
jinu1996
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...
0
10113
tracyyun
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...
0
6880
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();...
0
5547
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...
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.