- Web 2.0 Summit Opening Session
- Web 2.0 - A Conversation with Eric Schmidt
- JSF: The 7-Layer Burrito I Won’t Eat Again
- JSF: Leaky Abstractions (Grab a Mop)
- ZDNet Hebdo Podcast - 20 au 24 novembre 2006
- Vittorio Bertocci: WS-Trust - Under the Hood
- Identity
- Kim Cameron - Identity Laws
- InfoCard Explained
- Zdot Podcast: Why You Need Hibernate
- Zdot Podcast: Key Hibernate Features
- .NET Rocks! #204 - TechEd Europe Interviews
- XAML Application : very inspiring example of what you now can do with WPF rich clients.
- Podcast 01net. du 1er décembre 2006
Monday, 27 November 2006
What I listened to this week #2
Monday, 20 November 2006
Books I currently flip through...
Code...
Architecture...
- Patterns of Enterprise Application Architecture
- Head First Design Patterns
- Writing Secure Code
- Oracle Security
- Mythical Man-Month, The: Essays on Software Engineering, Anniversary Edition
- The Java™ EE 5 Tutorial, Third Edition: For Sun Java System Application Server Platform Edition 9
- Microsoft® Windows® Internals, Fourth Edition: Microsoft Windows Server™ 2003, Windows XP, and Windows 2000
Others...
Mixing legacy MFC code with Windows Forms (Part 2)
I know how to call unmanaged code from a managed class.
How to do the opposite?
This piece of code
returns the following error:
Error 1 error C3265: cannot declare a managed 'm_rigging' in an unmanaged 'MFCControls::DiagramContainer'
Hints:
http://www.ondotnet.com/pub/a/dotnet/2003/03/03/mcppp2.html?page=last
Solution:
Use gcroot
m_rigging can be used as a usual Rigging^ object. You reach the members using ->
public class DiagramContainer
{ private: // Managed reference to some dataRigging^ m_rigging;
};
public class DiagramContainer
{ private: // Managed reference to some data. gcroot makes it look like an unmanaged typegcroot<rigging^ > m_rigging;
};
Sunday, 19 November 2006
What I listened to this week #1
- ADO.NET 2.0 - Interview with Wally McClure
- Michael Surkan: Introduction to IPV6
- Windows, Part I - Dave Probert
- Windows, Part II - Dave Probert
- Windows, Part III - Dave Probert
- Windows, Part IV - Dave Probert
- Brandon Bray: VC++ 2005
- The Advancement of Windows: Ales Holecek - Windows Shell (Windows Explorer, Desktop Search, UAC, Aero)
- WS-* specifications
- Arun Kishan - Process Management in Windows Vista
- .NET Rocks! #203 - Bill Wagner and Diane Marsh on Non-MS Technology
- Sahil Malik on Sharepoint 2007 Part 1
- Next Generation Gaming Systems
- The Basics of Vocal Harmony
Friday, 2 June 2006
Mixing legacy MFC code with Windows Forms (Part 1)
I am looking into how to run legacy MFC code within a nice-looking Windows Forms framework. I built an MDI with Windows Forms and C# using ADO.NET. I have a large code base in C++: rather than rewriting the complete application from scratch (and therefore having to maintain and deploy 2 distinct applications, one in Windows Forms, one in MFC), I'd like to integrate the legacy code inside the new Windows Forms framework. This would allow for a smooth transition from MFC to Windows Forms.
I must solve two problems:
The Winforms C# App calls a C++ managed wrapper (derived from System::Windows::Forms::Control). Upon creation of its handle, the wrapper associates the handle with a CWnd-derived MFC class. The original code from the Codeproject article used C++ managed extensions. I compiled it with VS2005 so I had to translate it from C++ managed extensions to C++/CLI and it worked just fine.
This technique works ok with a CWnd-derived class. Unfortunately our legacy MFC code is based on property sheets so this is not going to be enough, but it’s a start.
However for some reason only the Release version of the executable worked. The Debug version kept displaying the following assertion,
an instead of displaying the appropriate line of code just got my machine to thrash.
Anyway this is still not quite what I want to do: my Windows Forms MDI framework is written in C#, not in C++. The legacy code must reside a DLL compiled in mixed mode.
I created the MFC dialog project with the Wizard then modified its properties:

I must solve two problems:
- use an MFC property sheet from a C# app
- manage ODBC and ADO.NET connections in a single exe
- An Overview of Managed/Unmanaged Code Interoperability
- MFC under the hood
- Native and .NET interoperability
- Using C++ Interop (Implicit PInvoke)
- Introduction to managed C++
- Intro to Managed C++, Part 2: Mixing Managed and Unmanaged Code
- C++/CLI Migration Primer
- Mixed (Native and Managed) Assemblies
- How to: Compile MFC and ATL Code with /clr
- Moving to .NET and WinFX: A Roadmap for C/C++ Applications
- Books:
- Extending MFC Applications with the .NET Framework (Tom Archer)
- Subclass System.Windows.Forms.Control
This technique works ok with a CWnd-derived class. Unfortunately our legacy MFC code is based on property sheets so this is not going to be enough, but it’s a start.
- One single C++/CLI App containing MFC legacy source and dialog templates.
However for some reason only the Release version of the executable worked. The Debug version kept displaying the following assertion,
Anyway this is still not quite what I want to do: my Windows Forms MDI framework is written in C#, not in C++. The legacy code must reside a DLL compiled in mixed mode.
- A C# Windows Forms project calls a dialog residing inside a mixed-mode exe
- Changed to DLL
- Switched on /clr
- Disabled pre-compiled headers.
- Same as above but using Alexey Shalnov’s MFCAppAdapter class
- Created an MFC MDI App with Visual Studio 2005.
- Added MFCAppAdapter.cpp (copied from Alexey Shalnov’s article).
- Changed MFCAppAdapter.cpp compile options to /clr (at the file level, not the project level).
- Set Code Generation option: set to default.
- Set Enable Minimal Rebuild option to No.
- Set Enable C++ Exceptions to Yes with SEH
- Set Debug Information Format to Zi
- Add references to System and System.Windows.Forms
Subscribe to:
Posts (Atom)