Solved

"CreateObject" in C# compact framework

Posted on 2004-10-20
12
781 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 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
Industry Leaders: 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

Industry Leaders: 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!

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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