|
I'm developing components in separate .dlls. Unfortunately I have to manually delete the compiled .dlls so that they are refreshed in the main project each time I change them? Is there any other way (automatic)?
It is the same story with the resources but I know it is an issue with VS.NET. It is quite annoying each time I change a resource I have to remove it and then add it again.
|
|
|
|
|
Remove the assembly references. Right-click on the project that depends on those assemblies, select Add Reference. Click the Project tab and add the projects in your solution that your current project depends on. Now a build dependency is established so that any changes in a dependent project (or their dependents, etc.) will force a recompile and - if necessary - will copy the newly built assembly into the target path for the project that depends on it. This also makes sure that the versions are never incorrect, though you really shouldn't use automatic versioning in larger solutions because versions in .NET are important (they are part of what defines a Type - a difference only in version results in different Types).
If you read the Visual Studio product documentation - or even just explore the IDE - you can find a lot more useful tips.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Well, all my projects are in the same solution from the start but most of the time, when I change any of the .dlls the newer versions are not copied in the .exe folder. Most of the time this happens only if I delete the bin folder and execute Build twice.
I have thought about outputting the compiled .dll directly in the main projects bin folder but I haven't tried it yet. there should be a more logical solution.
|
|
|
|
|
Cristoff wrote:
there should be a more logical solution
There is: as I said, reference your projects in a solution using the Projects tab - not the .NET tab. Trust me - I managed a solution of well over 60 projects as the senior software architect and build master for a very large, N-tier .NET application using VS.NET.
This will set up build dependencies and will update your dependent assemblies for a project that references them (directly and indirectly) in the target path (bin\Debug, bin\Release, etc.). And also as I said before, this is documented in the Visual Studio product documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you,
I have followed your suggestion and I think I have found your proposed solution.
I have been so convinced that adding an assembly reference is all I have to do that I have never thought that Project dependancy is something different.
BTW I have almost given up programming at the end of the last year and I haven't touched a compiler since then but the necessity has made me do it again
Your so helpful to the community! Thank you!
|
|
|
|
|
i m writting a C++ Win32 DLL which is called by a C# application.
i want the DLL can trigger an event to the Calling C# app after some operations which might like the Win MSG mechanism: The DLL send a message to the C# app and the C# app handle the msg.
the C# use the EventHandle/EventArgs on this issue.
But can i trigger an event to C# app in a C++ Win32 DLL ?
please help me.
|
|
|
|
|
If you pass a handle (the Handle property for controls) to your unmanaged DLL (P/Invoke is easy enough, and I assume you know how to do it), you could always call SendMessage in your unmanaged code to send a message to a control. In your control class (assuming you've extended a class), override WndProc and handle the message. Don't forget to call base.WndProc to continue processing all messages that go through the window procedure for the Control .
Another way is to expose your .NET component as a COM control (following correct guidelines, which aren't too obvious when reading the .NET Framework SDK but any COM developers should know). Your unmanaged code could instantiate a new or reference an existing instances and call a method that raises an event defined on your .NET component.
While my article isn't exactly about this, per se, it does offer a lot of insight into this method. Read Embedding .NET Controls in Java[^], which discusses bridging .NET and Java with C++ (JNI and COM). You shoudl find a lot of helpful information in there about what you're trying to do.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Hi Guys,
I developed a An approval page using c#. Our users want that after pressing the Complete button the current page with all the information will become an attachment of my email so that I can send this page to anywhere I want.
My first solution was to give a link from the email, when the person clicks the link it will redirect him to the page with the information based on the key as parameter. THe problem is we have users or vendors that doesn't have access to our server. They just want to have a copy of the information by email.
If you have any other ideas please let me kknow, I would appreciate it very much.
/dabuskol
|
|
|
|
|
What exactly do you mean by "page"? I assume you mean a web page and that you're talking about an ASP.NET site. If that's true, not only do you not have any control really what's on a client tmachine (all your code is sever-side, but client-side scripting might be a little helpful assuming your script is granted enough privileges), but you're posting in the wrong forum. Post in the ASP.NET forum here on CodeProject.
If you aren't referring to a web application, please elaborate.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Don't tell me - I didn't ask the question. Reply to the original poster.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I cannot figure out how to ask the user for input if a form should be closed (or application exited), when alt+f4 or the X button is clicked?
Is there an event being fired when the user clicks the X button (the one on the caption bar)?
|
|
|
|
|
|
sure but i've just missed that the
System.ComponentModel.CancelEventArgs.Cancel property has to be set to true
BTW is this call a good idea:
this.OnClosing(new System.ComponentModel.CancelEventArgs());
Here I raise the System.Windows.Forms.Form.Closing event, when a button Quit is clicked on (or another exit condition is met).
|
|
|
|
|
to Raise the Form.Closing event you need to just call:
this.Close();
|
|
|
|
|
OK I have actually found out how it is done. Here is what a I did (nothing specially, really). I happens to me too often the solution is obvious but I miss it.
buttonExit_Click... etc... is an event handler... is it how you are going to do it? Thanx
private void buttonExit_Click(object sender, System.EventArgs e)
{
this.OnClosing(new System.ComponentModel.CancelEventArgs());
}
private void FormOfficeTools_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
System.Windows.Forms.DialogResult result =
System.Windows.Forms.MessageBox.Show(this,
"Желаете ли да излезете от програмата?",
"Изход от програмата",
System.Windows.Forms.MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Question
);
if (System.Windows.Forms.DialogResult.Yes == result)
Application.Exit();
else
e.Cancel = true;
}
#endregion
|
|
|
|
|
You don't need to call Application.Exit (in fact, I recommend you don't). The only condition you have to worry about is anything that would lead you to set CancelEventArgs.Cancel to true . If you don't set it, the form will continue closing as normal. The .NET Framework SDK even has a good example for the Form.Closing event.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you, Heath Stewart
What's wrong with Application.Exit ? Why don't you recommend using it?
How should I then quit an application?
I'm looking for the Form.Closing event... and still can't find it.
|
|
|
|
|
Because the form is already closing. If the form is your main form - the one you passed to Application.Run , once it's closed the application will exit anyway. There may already be messages in the pump that were posted that may need to clean-up resources. Calling Application.Exit circumvents that. So, if you don't set CancelEventArgs.Cancel to true , the form will close and the application will exit just as if you hadn't handled the Form.Closing event.
And what do you mean you can't find it? It's documented in the .NET Framework SDK, and if you use the designer you can click the "Events" button in the PropertyGrid when your form is selected, find the Closing event and double-click it. You can also use IntelliSense.
The thing is, you're not looking for Form.Closing , you're looking for this.Closing or form1.Closing or whatever is appropriate for accessing your instance of your form. Some basic understanding of programming is assumed. Closing is an instance event, so it will be defined for an instance of your form (so access it using this or a variable that refers to your Form ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry, I have meant the Form.Closing sample you have mentioned about and not the event! I have made a pretty stupid mistake and haven't checked what I have written.
I understand about Application.Exit now. I thought that it isn't generally a good idea to use Application.Exit at all.
BTW I have replaced Application.Exit with:
private void buttonExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
Then I handle the Form.Closing event to ask the user if he really wants to quit etc. Is it a good idea or not? It seems to me like an implementation of your idea.
|
|
|
|
|
Yes, that is the way to handle it. Form.Close will send the Windows messages to close the Form . You're handling the WM_CLOSING message and optionally cancelling it. If you don't, the Form continues to close. When it's closed, if the message pump was waiting on it (i.e., you passed an instance of that Form to Application.Run ), then the application will exit.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yes there is... it's called Closing... and when you handle it you can do all kind of stuff (including cancellation of closing) with it
|
|
|
|
|
I was messing around in C# express and I though it was cool how everything is "visual styled". When I put a tab control on my form, the background is all fancy and has a gradient. that's great I say to my self... but then I add a label or something, and the backgrounds don't match - it looks really ugly. How can I fix this?
/\ |_ E X E GG
|
|
|
|
|
First search and - if not reported already - report a bug at http://lab.msdn.microsoft.com/vs2005/[^]. This has to do with the Theme API and how they're using it since a TabPage and GroupBox require owner-drawing with the P/Invoked Theme API. This was a known bug with .NET 1.x that they attempted to fix with .NET 2.0. As you can see, it still has problems (but it's beta, so now is the good time to report bugs).
Microsoft MVP, Visual C#
My Articles
|
|
|
|