?
Solved

CreateObject alike for WIA

Posted on 2006-07-11
5
Medium Priority
?
979 Views
Last Modified: 2008-10-01
Hi,

This is a code-snippet from a VB.NET print module

Dim dialog As Object = CreateObject("WIA.CommonDialog")
dialog.ShowPhotoPrintingWizard(vector)

I've tried this in C# as follows:
Type t = Type.GetTypeFromProgID("WIA.CommonDialog");
object dialog=Activator.CreateInstance(t);

But then I cannot access dialog.ShowPhotoPrintingWizard();

I've referenced the waauit.dll now and add using WIA at top.
But still I want to get the other way(without referencing WIA).

kGenius
0
Comment
Question by:kGenius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 17088141
Hi kGenius,
----------

you could try
object dialog = CreateObject("WIA.CommonDialog");
dialog.ShowPhotoPrintingWizard(vector);

----------
bruintje
share what you know, learn what you don't
0
 
LVL 44

Accepted Solution

by:
bruintje earned 2000 total points
ID: 17088172
disregard my first comment, what you are trying to do is not completely possible in C# because it is not in line with the strong typing used in C#

http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20855783.html

adapted from the comment of _TAD_

using System.Runtime.InteropServices;

Type myObjType;
object myObjValue;

myObjType = Type.GetTypeFromProgID("WIA.CommonDialog");
myObjValue = Activator.CreateInstance(myObjType);

myObjType.InvokeMember("ShowPhotoPrintingWizard", BindingFlags.InvokeMethod,null,myObjValue,vector);
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17090437
Is it possible to add a reference, and use early-binding, instead of the late-bound Activator call?

Bob
0
 
LVL 7

Author Comment

by:kGenius
ID: 17106334
It is possible in my app. I've done it that way (add the reference)
But I was so curious how C# could handle this one.

Thanks bruintje for sharing...
kGenius
0
 

Expert Comment

by:olecb
ID: 22612544
tmp is like this..: "c:/users/me/pictures/abc.jpg"...

What the compiler says is "argument can not be converted from string to "ref object"
If've refered to http://msdn.microsoft.com/en-us/library/ms630492(VS.85).aspx
where is said that also could used a path to afile....
WIA.CommonDialog myprintDialog = new WIA.CommonDialogClass();
String tmp = theBasisPfad + currentDateiname;
theDruckListe.SetFromString(tmp,false,true);
myprintDialog.ShowPhotoPrintingWizard( tmp );

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question