Solved

"CreateObject" in C# compact framework

Posted on 2004-10-20
12
780 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
12 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 500 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
designing in object programming 12 94
Reading the Web.Config using IIS 7.5? 4 47
How to repeat the data 4 17
C# Linq - Join two objects into one 3 13
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

839 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