|
Hi everybody . I got a little question about distributing a .Net C# Application. Many of you already did such things, and maybe you find the time to give me a hint on doing this
I created a small C# Application and I wish to upload it so that anybody can use it. I gave it to a friend for testing but the problem is that the Application crashes when you try to run the executable. The target computer already had the .Net Framework 1.1 installed.
What I sent to my friend is the executable and two DLLs. The program uses the WinSock control and the two DLLs are something like AxInteropWinSock.dll or something like this, the only difference is that one of them does not have the "Ax" in its name. This is not so important... what's important is that I sent the .exe and the two DLLs in the same folder. I took them from the "Release" folder of my .Net Solution, after I ran the solution using "Release" configuration.
I saw on the Internet stuff about using MSI files to make a setup or assemblies. I don't know how to use those and the Microsoft documentation is terrible. I would prefer to give this to somebody in a zip file, without any complicated setups and stuff like that. It's a simple application, I'd rather avoid using MSI files and so on.
Any help is greatly appreciated, thank you for your time and have a nice day.
Axonn.
The Greater Mind Balance
|
|
|
|
|
MSI is not a magic bullet that will solve your problems. Obviously, something is missing. If all you use MSI for is copying those assemblies into a folder, then something as simple as COPY or XCOPY or just zipping it up will do fine.
The difference between Interop.something.dll and AxInterop.something.dll is, by default, that the Interop assembly contains the typelib wrapper (RCW, or Runtime Callable Wrapper) and the AxInterop assembly contains the control(s) that extend AxHost , a Control which wraps ActiveX controls.
Distributing those assemblies isn't enough, however. Since they are only wrappers, you need to distribute the WinSock COM control that you're wrapping. All those assemblies do is make the COM control and typelib useable in .NET (through the RCW).
This is where MSI would be handy. COM controls need to be registered on the system and MSI can do that easily. You can add the file to the File System editor and in the file's properties (in the PropertyGrid), set the registration to SelfReg (something like that).
You don't need to do this, though. If you don't plan on mass-deploying this, just direct users to download the WinSock COM control and install it it, if it has it's own installer.
If you do want to distribute this to anyone, though, I'd recommend using an MSI package. VS.NET's Windows Installer projects are very simple to learn, but are by no means complete (for our installs, I use Wise for Windows Installer, which is a full-blown authoring package for MSIs and MSMs from Wise[^]). The VS.NET is simple to use and you should explore it a little.
For example, in the File System editor you can add folders to whatever pre-defined folder you want, then add your project outputs (handy when you want to maintain version compatibility within a solution). Just right click in the folders and seld Add File, choose Project, browse to the project you want and select Build Ouput. Now when you build the MSI project it will make sure the other projects are up-to-date and automatically grab the build outputs (the assemblies) from the projects' target directories.
Also add the COM control if the VS.NET Windows Installer project doesn't do it already (it often will). Make sure that it's set to register itself as I mentioned above.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you for your answer Heath. I can see why you are a MVP . The problem is that I`m kind of new to the .Net "peripherical utilities". I've been developing programs in .Net at work for a year, but I never had to distribute one. Now I made a little IRC client at home and I want to deliver it and I have problems...
Not to mention that I don't know what's that XCOPY or "File System Editor" and where I can find them. But I have MSDN and I will search, that's the least of my worries.
First of all... the File System editor can help me? I can add files to my project using that, maybe, but will it register the WinSock OCX control?
Can you tell me if the Windows Installer made be Wise is free?
Thank you, have a nice day
The Greater Mind Balance
|
|
|
|
|
XCOPY is a program used to copy files and has more features than the simple COPY shell command (it's not a program, but is implemented by the command shell).
The File System editor is a few of the file system in a Windows Installer package. Again, I encourage you to play around with it. It was designed to be simple (overly simple in my opinion, since I've been working with Windows Installer since MSI 1.0 beta).
Wise for Windows Installer is most definitely not free (it's a commercial application; it requires lots of time and money to develop), and you can find more information about it at the link I gave you in my first reply.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hmm... so the File System Editor is included in the Windows Installer package. Can you tell me where I can find that? MSDN is very obscure... I can't find anywhere something that says how to get to the File System Editor.
(Where it is located on the hard drive or where I can find it using menus or stuff like that)
Another question. Would it be enough to use regsvr32.exe to register the winsock ocx on the target machine?
Thanks again
The Greater Mind Balance
|
|
|
|
|
It's part of the Windows Installer project package. Select your Installer project in VS.NET (after adding one, of course), and select View->Editor->File System, or click the "File System Editor" button above the Solution Explorer with your installer project selected (or something in the project).
If you don't want to use an installer, yes, you can run regsvr32.exe on your WinSock OCX to register it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Pfiuu , yes, this will surely work. Thanks a lot for your help, I got several solutions to investigate now... ... Have a nice day Heath (and everybody else too) .
|
|
|
|
|
Hy everyone!
What I do want to do is sending information of my Windows Application (some Textboxes) via LAN or net to a server (apache and/or tomcat).
My Application is written in C# in Visual Studio 2003 and the server will be implemented in JAVA. So we decided on SOAP and XML for the communication between the server and the client (= my Windows Application).
So I had a look for some infos on SOAP and how to implement the main modules, but 'til now I wasn't successfull.
So it would help me a lot if someone told me how to do this.
Thanks.
Stephan.
|
|
|
|
|
Did you develop your application without looking ONCE into the .NET Framework documentation?
|
|
|
|
|
thanks for the hint, I guess I had overlooked it, but now I have found the relating chapter (13) in the documentation!
Stephan.
|
|
|
|
|
Hy everyone!
I do have a problem with importing Outlook contacts!
I do use Outlook 2000 and my aim is to drag and drop Outlook contacts into my C# application (which is a Windows application) in a Textbox.
I managed the drag&drop methods but I do only want to insert the telephonenumber, lets say the business number and NOT the whole contact. I added the reference to the Outlook9 library but wasn't able to change my methods to only get the number.
Does anyone of you know what I do have to change/add or what ever to make it work?
The relevant part of my source is following this message!
Thanks!
Stephan.
Source:
...
//
// txtNameKey01
//
this.txtNameKey01.AllowDrop = true;
this.txtNameKey01.Location = new System.Drawing.Point(192, 24);
this.txtNameKey01.Name = "txtNameKey01";
this.txtNameKey01.Size = new System.Drawing.Size(160, 20);
this.txtNameKey01.TabIndex = 39;
this.txtNameKey01.Text = "";
this.txtNameKey01.DragDrop += new System.Windows.Forms.DragEventHandler(this.txtNameKey_DragDrop);
this.txtNameKey01.DragEnter += new System.Windows.Forms.DragEventHandler(this.txtNameKey_DragEnter);
...
#region txtNameKey Drag&Drop Actions
///
/// Drag&Drop routines for txtNameKeys
///
/// <param name="sender" />
/// <param name="e" />
// event handler for the DragEnter Event for txtNameKey
private void txtNameKey_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
// event handler for the DragDrop Event for txtNameKey
private void txtNameKey_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
// eliminate +,(,)
string temp, temp2;
int i=0;
temp2="";
temp = e.Data.GetData(DataFormats.Text).ToString();
TextBox lTextBox = sender as TextBox;
for (i=0; i
|
|
|
|
|
The typelib won't necessarily help you. Your application needs to be able to understand the clipboard format - and there are many - so picking the right one helps.
The Outlook typelib is for programmatic access to the objects used by Outlook. Very rarely do typelibs assist with parsing clipboard formats.
You should download Mike Dunn's ClipSpy[^] application from this web site (there's others like it, but his is pretty nice). If you drag and drop a contact onto the application window, it will enumerate all the clipboard formats supported as well as show you the data in a hex viewer that the clipboard formats contain.
Then, just use GetData("whatever clipboard format") , instead of the very limited and most basic clipboard formats in the DataFormats class (in actuality, clipboard formats are registered strings).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Well thanks for this hint!
It says:
RenPrivateSourceFolder
RenPrivateMessages
FileGroupDescriptor
FileContents (grayed out)
Object Descriptor
CF_TEXT
The telephonnumbers can only be found in the last type.
Because I do only want to extract the telephone number(s) of the contacts. If there are more than one (business and mobile e.g.) that's another thing, but in general, I do only want to extract the number and leave the rest behind.
So I have to use the Clipboard Format Text (like it said in Google).
But well, where and how do I get to the Clipboard Format??
Maybe an example of some code will extinguish my confusion (e.g. how my example should look like, especially the type in braces!)
I am familar with C/C++ but well, C# is different but somehow similar as well. So I am quit new to programming in C#, trying to port my knowledg of C/C++ and trying to understand the rest!
Maybe someone of you out there could hint me to what I have to do, because in the MSDN I found nothing and everything I found about CF_Text googling the web, wasn't C#!
Thanks!
Stephan.
|
|
|
|
|
The CF_TEXT clipboard format is the same as DataFormats.Text in the .NET BCL. Both are simply defined as "Text" (actually, CF_TEXT is a pre-registered ATOM, IIRC, defined as 1).
So, as you posted before, just use dataObject.GetData(DataFormats.Text) and parse the text to get only the phone number. Because of the variability, you might consider using a string tokenizer or the System.Text.RegularExpressions.Regex class for regular expressions.
FYI, C# really has nothing to do with this. Since you're new, it's important to understand that C# is one of about 30 languages currently that target the Common Language Runtime (CLR). C# has access to the same classes as any other language. The Microsoft .NET Base Class Library (BCL) is the assemblies that comprise the .NET Framework, but any assembly can be used by any language because they all compile down to the same Intermediate Language (IL) that is contained in a module which is embedded into an assembly (which may also contain assembly attributes and embedded resources, and always has a manifest of what it contains).
So, the clipboard and drag-n-drop functionality is actually provided by the BCL assemblies (System.Windows.Forms.dll, specifically). While the same level of functionality is not exposed by the BCL classes, the OLE clipboard and drag-n-drop functionality is encapsulated and used (otherwise you wouldn't be able to drag-n-drop out of your .NET application). I'm currently developing a library that does expose all the functionality in a .NET-friendly manner, but it will be quite some time before it's done (I don't exactly have a lot of time).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
somebody can explain about SNTP Class?
thanks
Nho'c Ti`
|
|
|
|
|
This forum is for discussions about C#, not SNTP. You can read about SNTP by reading the RFC, which can be found at - among many other places - http://www.faqs.org/rfcs/rfc2030.html[^]. There are many other sources available for SNTP. Just google or something.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello.
I have red Code project articles on implementing Undo and have come to the conlusion that the best and easiest way for doing it is Undo and Redo the "Easy" Way and have found it very interesting. The question is. Can i do it in C# and if yes, does naybody have some premade code.
Only Absolute Power and Absolutely No power matters. The rest is slavery.
|
|
|
|
|
It is an interesting concept, but probably not so very well suited for the .NET world with its own memory manager and a garbage collector, also the word "easy" in the article name is in quotes for a purpose. You will be much more better of with an implementation of a "Command" OO design pattern, which will allow your app to support the same functionality but much more elegantly.
|
|
|
|
|
To display the vertical scroll bar of any control (Print Preview Control in perticular)which window message is set?
pls guide
|
|
|
|
|
A windows message is not "set" - it is sent. For controls that support it (not every control does), you can set the WS_HSCROLL (0x00100000) and WS_VSCROLL (0x00200000) window styles by overriding the CreateParams property:
protected override System.Windows.Forms.CreateParams CreaeParams
{
get
{
System.Windows.Forms.CreateParams cp = base.CreateParams;
cp.Style |= WS_HSCROLL | WS_VSCROLL;
return cp;
}
}
const int WS_HSCROLL = 0x00100000;
const int WS_VSCROLL = 0x00200000; Most controls that support scrollbars in the Windows Forms library already have properties that control these.
Again, not every control supports them. As for the Windows Common Controls, see the Windows Controls[^] documentation and reference in the MSDN Library.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
It works, but the scroll bars immidiately disappear as soon as the document is displayed.
I tried in different way, as suggested by my friend
[System.Runtime.InteropServices.DllImport("user32")]
public static extern int ShowScrollBar(int hwnd, int wBar, int bShow);
private void ppcDocViewer_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
int i = ShowScrollBar((int)this.ppcDocViewer.Handle, 1, 1);
}
It works fine.
What would be the best way?
|
|
|
|
|
ShowScrollBar is a macro that does what I mentioned before. Use that if you like; if nothing else, it's less code to define.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is there any way to implement object registration with a class factory similar to the static object constructors of C++? I’m trying to avoid having one location with a HUGE list of initializers.
For example this could register a type with a factory in C++
<br />
class MyNewClass<br />
{<br />
};<br />
<br />
static ClassFactory::Register<MyNewClass> gMyNewClassRegister;<br />
In C# the only way to do this that I can find is by manually calling a register function for each type which will result in long lists of using namespaces and register calls.
|
|
|
|
|
Typically, this is done using a .config file, where types (as strings, like "System.String, mscorlib") are defined. You could easily create an IConfigurationSectionHandler (or re-use an existing one like the NameValueSectionHandler ) that reads these in the first time your configuration section is accessed (it's cached after that, so changes must be to the settings class or the app must be restarted). You could, for example, read these into a class with a static property that is an IList or IDictionary (typed class, if you want) that may be read-only or read-write (if you want to change it at runtime).
When you want to create an instance of a class, you pass some token (perhaps the string name or some friendly name) and the type is created.
This is actually how much of the .NET Framework BCL works, especially in .NET 2.0 (which uses the provider pattern heavily). In our own flagship application I designed, callers pass the type of interface for which a proxy should be instantiated. The configuration class finds the type string for that interface and instantiates the proxy. All calls to the proxy are late-binding calls to the interface.
You should search CodeProject for "configuration settings" or something along those lines for examples.
In this scenario, your settings class (the instance the IConfigurationSectionHandler creates) is the factory. Registration is done by adding types to the .config file, or adding them at runtime (perhaps you want to support some built-in types that should always be present).
If you want to use this provider pattern with the new operator, you should take a look at the ContextBoundObject class documentation in the .NET Framework SDK. By attributing a derivative class with the ProxyAttribute and implementing your own RealProxy , you can intercept IConstructionCallMessage and create an appropriate type. Perhaps the constructor would take a Type or a String , and your RealProxy derivative uses that parameter to actually create that type and return it. Of course, that Type should abide by some contract - perhaps even extending the class that the caller believes they are instantiating.
You can find more information about this at MSDN[^] and here on CodeProject. Search for AOP - or aspect-oriented programming. This isn't AOP specifically, mind you, but uses concepts that are very similar (proxying calls to another context so that transform sinks can be inserted in a chain easily, which is essentially what your class factory is in this scenario).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have an application that I want to put on a network drive so everyone runs the same executable. The problem is that once it is on the network drive, I get an authentication error.
I found UB's article Understanding .NET Code Access Security and tried go through his example. I have the .snk file and I know it is loaded (if I rename it, I get a compile error) but I don't get the lock access he describes and demonstrates. I'm at a loss to this.
Two things:
1) Are there some other links available to identify what I need to do to the executable and associated .dlls to allow/control network access? Also, I got the impression I will have to configure security on each PC that accesses this file (multiple files when including dlls). This does not seem to present a very managable solution.
2) With 100+ people in the company, is there a better way to manage the executables? Right now, when an update is done, it is a process of going to each workstation and copying it down. This is the primary reason to switching to network access.
Thanks
|
|
|
|
|