Solved

"CreateObject" in C# compact framework

Posted on 2004-10-20
12
776 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
(code works) but print excel in Landscape 5 49
LINQ question 7 21
Hide Tab Page 3 18
Performance  Html.BeginForm vs jQuery 3 11
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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now