c#


write a com control in c# and use it in MFC


if this possible to write a com control or activex in C# and use it in MFC ?
Yes. First, you need to create COM object. Below is a very simple example.
[Guid("123565C4-C5FA-4512-A560-1D47F9FDFA20")]
public interface IDoSomething
{
[DispId(1)]
string Name { get; }
[DispId(2)]
int DoSomething();
}
[ComVisible(true)]
[Guid("12AC8095-BD27-4de8-A30B-991940666927")]
[ClassInterface(ClassInterfaceType.None)]
public sealed class DoSomething: IDoSomething
{
public DoSomething()
{
}
public string Name
{
get { return ""; }
}
public int DoSomething()
{
return 4; //random number
}
}
After that you need to regasm your assembly. The regasm tool will add the necessary registry COM entries:
regasm.exe /tlb component.dll
/tlb is necessary to generate the type library to be imported in your MFC application.
Once your assembly is registered, you can call DoSomething in your MFC application like any other COM objects.
Check this link for more information.
This is a bit outside my normal territory, as I don't interact with .NET Interop technology all that much.
It is possible to create what's called a COM Callable Wrapper around your C# control/class to make it accessible to any COM-aware program. I won't duplicate Francis B's answer because it's fairly complete as it stands.
The big question is whether a visual C# control works seamlessly within an MFC window. That's not something I can answer, but my best advice would be to prepare for a bumpy road ahead. Please see http://bytes.com/topic/net/answers/430618-c-control-mfc-window-frame for more detail.

Related Links

C# store contents from DB into list
Is it possible for Selenium to open an Excel Workbook pragmatically
MSAL. Detect revoked permissions and perform re-authorization
entity framework ado.net error SaveChanges()
Do I really need to clear a local list?
how to fill one jagged array from another one in c# [closed]
How to listen to events from a URI (C#)? [closed]
Web api internal server error [duplicate]
Stateless 3.0 - State Machine Library Best Practice
Why does regex match capture the whole string as a group in C# when the whole pattern does not have an enclosing parentheses? [duplicate]
How to Transition to new DialogStack in the middle of a FormDialog
AVG blocks me from using Console.ReadKey() in C# Visual Studio 2017?
XslCompiledTransform in ASP CORE
ASP Create own Update Statement in sqlDataSource
How do I integrate APIs from (https://www.bittrex.com/Home/Api) into my blog using C# [on hold]
C# streaming drone video

Categories

HOME
autohotkey
swift3
netty
mobile
cxf
azure-database-mysql
boxplot
lithium
app-store
overrides
artifactory
richtextbox
atlassian-fisheye
sitemap
ephesoft
annyang
obd-ii
minimax
spring-data-solr
olap
theory
osclass
derby
owncloud
template10
beacon
conditional-formatting
spring-webflow
git-branch
cherrypy
klipfolio
fastboot
quality-center
suitescript
expressionengine
tftp
workflow-foundation
hierarchical-data
proof-general
boosting
kundera
delphi-2010
2checkout
edirectory
ios9
schedule
jmsserializerbundle
akamai
log4net-configuration
unity3d-5
rtos
imageprocessor
extern
console.readline
jibx
word-wrap
cowboy
observer-pattern
android-graphview
piranha-cms
emacs24
extjs3
runtime-permissions
e4
totalview
grib
group
scanf
recursive-query
portaudio
zsh-completion
firebase-polymer
db2-zos
queuing
supervised-learning
audiorecord
angular-i18n
nd4j
datamodel
bluetooth-lowenergy-4.2
glog
service-broker
douglas-peucker
xmla
optimistic-locking
pysvn
register-allocation
sync
livescript
cs193p
farpoint-spread
html5-filesystem
starling-framework
mdp
google-voice
raddatepicker
panelgrid
dd4t
volatility
google-email-audit-api
towerjs
yii-cactiverecord
apache-commons-email
lightopenid
lgpl
glassfish-embedded
hp-trim
dgml
coderush-xpress
ironpython-studio

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App