|
Dear all;
Recently our organization needs to convert a 3rd party’s MFC class library into managed code for usage in .NET. In the SDK, there is a header file and a dll library.
I only have little knowledge on wrapping unmanaged code to managed code. I would much appreciate if any one could give advice on how to implement.
Below shows the code in the header file for the dll library. I am quite confused on how to deal with the nested class and callback functions.
////////////////////////////Header File///////////////////////////////////////////////////////
#pragma once
#ifdef UNMANAGEDCODE_API_EXPORTS
#define UNMANAGEDCODE_API __declspec(dllexport)
#else
#define UNMANAGEDCODE_API __declspec(dllimport)
#endif
#include <sys/timeb.h>
class UNMANAGEDCODE_API MainClass
{
public:
MainClass ();
Virtual ~MainClass ();
Virtual bool StartUp(const TCHAR* pcszConfigFileName = NULL);
class NestedClass1
{
public:
// This is the entry for call back function
virtual bool OnNestedClass1() = 0;
};
Bool SetCallback(NestedClass1* callback); typedef struct NestedSruct1
{
unsigned int unId;
__timeb64 createTime;
}NestedStruct1;
const NestedStruct1** GetData(unsigned int& unCount);
};
|
|
|
|
|
I have developed an AxctiveX as COM object
As there noone know how to realize new ISiteLock interface in C# I want to know is there a way to get URL of a page from ActtiveX?
Thanks
|
|
|
|
|
hi i needed to accept amharic string from user with out turning on the visual geez software in vb.net. i tried so many techniques but none of them work. if anyone have dealt with this issue please help me??? thanku
|
|
|
|
|
change your programing language to c++ and I will tell you there answer
|
|
|
|
|
Hi,
I am using Entity framework in a dynamic data web app with C#.
So far I have created a source file with partial declarations of my entity classes on which I have set attributes like ScaffoldTable.
I did that in order to not lose this code in case of regeneration of the entity classes.
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace AdmissionForm
{
[ScaffoldTable(true)]
public partial class AdmissionForm
{
}
...
}
I would like to know if there is a way to add attributes to the properties defined in this entity classes from the source file I have added.
Regards.
|
|
|
|
|
|
Hi,
I want to develop a service in C# ,that will run on the exchange server. The service will monitor a particular email account whenever send/receive happens the service will forward the arrived mail to a specified email id.
Kindly guide me through this.
Thanks
|
|
|
|
|
deepak_int wrote: I want to develop a service in C# ,that will run on the exchange server. The service will monitor a particular email account whenever send/receive happens the service will forward the arrived mail to a specified email id.
Yes, you can do it using EWS(Exchange Web service)
Exchange Server 2007 provides Web Service (EWS), you have to use those web methods to read and forward those mail.
Brij has already written some nice article on that Exchange Server Web Service Article[^]
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
thanks for ur suggestion Abhijit.
|
|
|
|
|
OK, this may be a somewhat dumb question but I haven't found a definitive answer yet so I thought I'd try here.
I currently have a client/server WinForms app developed using .NET 3.5 framework. So all my users have .NET 3.5 installed on their PCs along with the application.
I would like to install .NET 3.5 SP1 on my development machine, basically since it's supposed to solve a lot of performance issues with VS2008. However, do I need to have all the users upgrade to .NET 3.5 SP1 as well? That will be a major effort that I don't want to do at this time. So if I'm required to re-deploy .NET 3.5 SP1 to all users in order to run an application developed using SP1, I'll hold off with upgrading my development machine, otherwise I'll press.
Thanks in advance... Steve
|
|
|
|
|
PSU Steve wrote: I haven't found a definitive answer yet
Short of just saying "yes it's required", isn't that up to you to answer? I mean you know what your app does, what it uses in the .NET framework, no one else does. So since Microsoft has documented SP1[^], isn't it up to you to figure that out rather than expecting to find a definitive answer from someone else?
|
|
|
|
|
I was really hoping for a little assistance as most people here at CP are helpful versus just sarcastic...
That said, I guess what I am really asking is this... If I (A) install .NET 3.5 SP1 on my development machine to take advantage of the supposed VS2008 performance fixes, (B) recompile my application "as-is" (ie making no changes specific to anything in SP1), and (C) deploy the app to my users who still have the "basic" .NET 3.5 framework, will it work?
Thanks... Steve
|
|
|
|
|
From my experience, yes it will work, but sp1 adds few functions, if you ship program that uses one of those, it will work as long as this function won't be executed. When it does, exception will be thrown (missing function). I don't know how much of this is help, cause I can't prove it will work the same way everywhere.
But after my app crashed once, I ordered my client to download update and don't whine :P.
|
|
|
|
|
Ravadre wrote: From my experience, yes it will work, but sp1 adds few functions, if you ship program that uses one of those, it will work as long as this function won't be executed.
Are there any automated programs that can take an .exe and determine whether it references any functions that don't exist in particular versions of .net? To be sure, it would be possible for a program that references a function only found in a later .net version to work with earlier ones if the function is never actually executed, but outside of code specifically written to handle different versions of .net (e.g. try using the new version of a function and set a flag based upon whether it works; if it doesn't work, use the old one instead) I would think the list of functions referenced would correspond strongly to the list of functions required.
|
|
|
|
|
I haven't heard of one, but I must say - I wasn't looking for one, so don't take this response as definite answer.
|
|
|
|
|
PSU Steve wrote: versus just sarcastic...
There was nothing sarcastic about my response, I was dead serious. So f*** off a**hole
Ok, look I might have been unfair........ to everyone you currently work with and anyone you might work with in the future. For all of those peoples sake you should look at this[^].
modified on Thursday, March 19, 2009 10:33 AM
|
|
|
|
|
The definitive answer is "Maybe". No, I'm not kidding around.
You're going to have to recompile the app under SP1, then install it on a machine without SP1 on it and test it. It's that simple! It's the ONLY way you're going to get the DEFINITIVE answer.
"led mike" was correct in every way, only YOU can answer that question: "will your app work??" You're not going to know until YOU test it, and that testing is not limited to strictly functionality. The other question you have to answer is performance. Sure, the app may work, but does it do so with acceptable performance??
|
|
|
|
|
Dave Kreskowiak wrote: "led mike" was correct in every way
Holy frack! What's next, hell freezing over?
I don't know if I can resist making that my sig.
|
|
|
|
|
You could always extend this to
"led mike" providing correct solutions since 2006.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
Pete O'Hanlon wrote: "led mike" providing correct solutions since 2006.
Good grief has it been that long? Wow, I may have to consider retiring.
|
|
|
|
|
Did I stroke your ego a little too much there?
|
|
|
|
|
Sp1 contains two types of stuff.
1) New libraries (e.g. the entity framework).
Provided you don't go using these, it won't matter that your users don't have them. You will need to be very careful to make sure you don't accidentally use some new sp1 functionality that your users don't have.
2) CLR improvements. (e.g. various performance improvements to WPF loading times etc). It doesn't matter that your assembly is compiled against 3.5 SP1 on your PC, it will still work on a PC with just plain old 3.5, but you just won't see any of the improvements.
So in theory it should work fine, but as with anything in development, I wouldn't bet your life on it. The best way forward is probably to ensure you test thoroughly on a 3.5 pc without sp1 before deploying it to your users.
Simon
|
|
|
|
|
Is there implementation SiteLock interface for ActiveX on C#?
or C# and .NET is not good option to make ActiveX?
Thanks
|
|
|
|
|
Hey Dudes (Dudets),
I read this awesome article IDisposable: What Your Mother Never Told You About Resource Deallocation[^] and a bunch of other not so awesome ones.
However, I failed to find an answer to this question:
1. I got a base class - ObjectA that inherits from a UserControl.
2. ObjectA is then inherited from by ObjectB and tailored to particular uses elsewhere in the code. (ObjectB is not inherited from)
3. There are many different ObjectB implementations (ObjectB1....10) all of which add EventHandlers for ObjectA events and declare their own distinct events that are handled by other objects.
4. Now all ObjectBx objects are stored in a collection and then disposed off like so:
For Each oA as ObjectA in CollectionOfObjectBx
oA.Dispose
Next
5. Each ObjectBx overloads Dispose method and uses it to Remove EventHandlers.
However, these Dispose overloads never get called because instances of the ObjectBx are disposed via the base class that is not aware of anything going on inside inherited objects.
But does it matter? Want GC eventually kill off all handlers since the objects themselves are dead?
I would greatly appreciate if anyone could shed some light on this.
Regards
Alex
"All your base are belong to us..."
- Mr. Cats (2110 A.D.)
|
|
|
|
|
Hi, you need to override and not overload. all dispose methods should be called from the leaf type to the top. I think that you should clean up after your self when creating objects that are disposable. in large objects you should also set values to null explicitly to free the memory faster. The next code calls all methods when disposing:
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
//This code should go in the main
//ObjectB1 inherits from ObjectB which innhertis from ObjectA
ObjectB1 b1 = new ObjectB1();
//Calling the dispose will call the dispose of ObjectB1
//within the dispose of ObjectB1 there is a call to the base dispose.
b1.Dispose();
}
public partial class ObjectA : UserControl
{
public ObjectA()
{
InitializeComponent();
}
private void ObjectA_Load(object sender, EventArgs e)
{
}
}
public class ObjectB : ObjectA
{
public event EventHandler ObjectBEvent;
public ObjectB()
{
this.MouseClick += new MouseEventHandler(ObjectB_MouseClick);
}
void ObjectB_MouseClick(object sender, MouseEventArgs e)
{
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
MessageBox.Show("Dispose : ObjectB");
ObjectBEvent = null;
}
protected virtual void OnObjectBEvent(EventArgs e)
{
if (ObjectBEvent != null)
{
ObjectBEvent(this, e);
}
}
}
public class ObjectB1 : ObjectB
{
public event EventHandler ObjectB1Event;
public ObjectB1()
{
this.MouseClick += new MouseEventHandler(ObjectB1_MouseClick);
}
void ObjectB1_MouseClick(object sender, MouseEventArgs e)
{
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
MessageBox.Show("Dispose : ObjectB1");
ObjectB1Event = null;
}
protected virtual void OnObjectB1Event(EventArgs e)
{
if (ObjectB1Event != null)
{
ObjectB1Event(this, e);
}
}
}
Natza Mitzi
|
|
|
|