Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

"CreateObject" in C# compact framework

Posted on 2004-10-20
12
Medium Priority
?
797 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
[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
  • 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

609 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