Programming
NLog.config Publish
by alowe on Jul.01, 2009, under Programming
NLog documentation state that “Copy to Output Directory” myst be set to “Copy Always”, but you must also select your “Build Action” to “Content” or else when you publish your project for users to use, the NLog.config file will not be included in your project.
Including an ActiveX Component
by alowe on Jul.01, 2009, under Programming
Visual Studio has an awesome deployment system, where publishing a project or updates are really easy.
However, if you are publishing with an ActiveX (COM) component it is not included (the actual .ocx file – the dll’s required to communicate with the component are included, just the actual ActiveX component is not). I was having this problem when trying to publish my application that uses the embedded Foxit ActiveX Control, which is really quite good.
What you need to to is publish with the COM component “Isolated”:
- Open the Solution Explorer
- Go to References
- Right click the reference for you ActiveX (COM) component – it will be the dll, not the ocx file.
- Open the properties
- Change the “Isolated” property from False to True
Publish your build, and the component should be included.
Also, you will probably need to include stdole.dll – in the Application Files section of the Publish tab you need to manually set the Publish Status to Include
Reference: http://msdn.microsoft.com/en-us/library/ms165432(VS.80).aspx
Application Exit in a constructor
by alowe on Jun.24, 2009, under Programming
Calling System.Windows.Forms.Application.Exit() in a forms constructor does not work!
Instead call it from Shown event.
Also note, that it does not immediately exit…. but continues on with the rest of the function you bound to the shown event, so you will need to run it in an if statement or return immediately:
if(value==null)
{
System.Windows.Forms.Application.Exit();
return;
}
// rest of the funciton here...
Also note, I specify the full namespace of the function Exit() for completeness, you probably have a using System.Windows.Forms already at the top of your file, so you probably only need to call Application.Exit().
C# Soap Client Quick Example
by alowe on Jun.23, 2009, under Programming
Basic Template for running a soap client query
replace “service” in any parameters with the name of your service.
// Create a portType from a portTypeClient
servicePortType newPort = new servicePortTypeClient();
// Create a new object of the operations parameters
serviceService parameters = new serviceService();
// fill in some details of the object
parameters.part1 = new part1();
parameters.part1.partA = 1;
parameters.part1.partB = "Text String";
parameters.part2 = "Text String";
// run the query
serviceServiceOutput response = servicePort.serviceService(new serviceServiceInput(parameters));
// use the result
if(response.serviceResponse.result == 0)
{
MessageBox.Show("The result was successful");
}
else
{
MessageBox.Show("The action failed with the result code: " + response.serviceResponse.result.ToString() + " and the message: " + response.serviceResponse.message);
}