?
Solved

"CreateObject" in C# compact framework

Posted on 2004-10-20
12
Medium Priority
?
803 Views
Last Modified: 2008-02-01
Hi there!

I need to "CreateObject" in C# (for a PocketPC, compac framework) how do I do that?

Here is how its done in eVB

Public myobj As Object

Set myobj= CreateObject("myDLL")
myobj.myfunction


Thanks!

0
Comment
Question by:kennetand
  • 6
  • 4
11 Comments
 
LVL 8

Expert Comment

by:tomvergote
ID: 12360956
you  can't

you should add a reference to your dll from your project, then visual studio will generate a .NET wrapper (interop assembly).
Then you can just instantiate your objects like
MyDLL.object objMyObj = new MyDLL.objecf();
objMyObj.myfunction();
0
 
LVL 8

Expert Comment

by:tomvergote
ID: 12360972
if youre not using visual studio there is also a tlbimp.exe in the SDK which will generate the wrapper for you.

an interop assembly does however require the original vb6 or whatever dll to be registered on the system
0
 
LVL 7

Accepted Solution

by:
God_Ares earned 1000 total points
ID: 12361342
well you ware using evb, right??

You can not use that call,.. why? Cause evb supports COM objects, which cf does not. If you want to use your unmanaged dll you have to p/invoke. What dll are you trying to use< or what function?

regards

Floris Briolas

ps:
EE is a great place but for cf.net I STRONGLY reccomend www.opennetcf.org and the microsoft cf.net framework newsgroup.

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:tomvergote
ID: 12361416
c# does support COM objects, it goes through interop but it works perfectly.

p/invoke is only really used if you want to use win32 api calls like in win32.dll or something (which you wouldn't want a runtime callable wrapper for)
0
 
LVL 7

Expert Comment

by:God_Ares
ID: 12361462
tomvergote ,.. COMPACT framework ??? You are shure??
0
 
LVL 8

Expert Comment

by:tomvergote
ID: 12361639
euh no, indeed God_Ares is right and worthy of his nickname :)
0
 
LVL 8

Expert Comment

by:tomvergote
ID: 12361649
I'll post a link but ares deserves the points:
http://msdn.microsoft.com/netframework/programming/interop/default.aspx

scroll a bit down for compact framework
0
 
LVL 7

Expert Comment

by:God_Ares
ID: 12362527
a ppt i sqw at a mobility developer day
there is no com support in cf 1.0 till 1.1
http://www.technologia.net.pl/seminaria/prezentacje/mobility_20030605/ADVANCED.PPT#521,14,Architecture


but Yes Com support is comming in cf ver 2 not sp2.  
0
 
LVL 7

Expert Comment

by:God_Ares
ID: 12367762
btw cf ver 2.0 (or vs.net 2005 is comming summer 2005 juli or june)
0
 
LVL 8

Expert Comment

by:tomvergote
ID: 12584023
I suppose your problem should be solved by now? could you provide some feedback?
0
 
LVL 1

Expert Comment

by:timmonks
ID: 21744058
Here is the VB code that does what you want
#If Not WindowsCE Then
                var = CreateObject(progid)
#Else
                Dim t As System.Type = System.Type.GetTypeFromProgID(progid)
                var = Activator.CreateInstance(t)
#End If

Open in new window

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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.
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

850 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