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

Change DB connection string after publishing a C# console app
excanvas js is not working in IE8 [duplicate]
count number of identical elements in two arrays in linq
WCF logging, set max file size?
LINQ concatenating elements in two string arrays [duplicate]
Trouble with PrintForm Control in C#
Array of different generics
Find node when traversing tree
Differences in event handling in C#
The request was aborted: The connection was closed unexpectedly
Migrate AIX 5.3 crypt function to C#
What is the point of groupBox in WFA in C#?
c# Equivalent of Err in vb
Managed VCL.Arrow keys and Tab key
JavaScript - Escape single quote in the JavaScript Object property value
C# Are the variables inside the static methods initialized in the beginning or when the method is called first?

Categories

HOME
service
jenkins-pipeline
wifi
mysqli
casting
opencv4android
gaussian
assign
opengl-es
google-docs-api
localhost
servicenow
opacity
pdf-generation
token
angularjs-ng-repeat
oxid
mbed
fastreport
repeater
multibinding
game-engine
openscad
amazon-data-pipeline
versioning
civicrm
conditional-formatting
xforms
android-navigation-drawer
multipart
hololens
concatenation
visual-studio-community
orgchart
azure-table-storage
hierarchy
folder
mobile-development
n1ql
machine-code
incapsula
wit-ai
wunderground
ponylang
matrix-multiplication
yelp
pygraphviz
idea-plugin
vpython
rexx
ionic2-select
serialversionuid
petapoco
multi-select
dynatable
stringbuilder
blitz3d
zsh-completion
glade
settext
require-handlebars
netlink
objectify
hana-sql-script
jersey-test-framework
dnvm
xml-simple
clearquest
web-standards
jeet-grid
cs193p
sendy
winrun4j
rssi
slimscroll
pthreads-win32
mixradio
db2-connect
nop
svg-android
grape-api
latex-suite
string-length
linqdatasource
qt5.1
screensharing
inflate
helicontech
scriptmanager
wdm
auto-compile
zipstream
norton
simultaneous
large-data-volumes
glassfish-embedded
hp-trim
jgrowl

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