|
Out of curiosity, are you using VS2002 or VS2003? My colleagues tell me that VS2003 will prompt to download the .NET runtime if necessary. I haven't been able to test that on a virgin machine.
|
|
|
|
|
Hi,
I recently had to build a installation program to install my application and I tried to do it using the "Deployment" project in Visual Studio.Net. After much research and help from the folks on this message board I was able to build the installation package.
There are 2 things to be done:
1. Create a new project of type "Deployment" and add all the components of your application to this project. You can specify the folders they need to be on the target computer, the icons/shortcuts on the desktop, the item in the Start->Program Menu, etc.
On building this project it will generate a .wsi file, a setup.exe along with other files. All the files generated in the Debug directory constitute the installation package.
The above package will run perfectly on any computer as long as it has .NET framework installed on it. If not then you have do the second thing.
2. Download the BootStrapper sample from the following link:
http://www.microsoft.com/downloads/details.aspx?FamilyId=BF253CFD-1EFC-4FC5-BA7E-6A6F21403495&displaylang=en
Its in unmanaged C++. Build it and it will generate a setup.exe. It also has a settings.ini file.
Copy the setup.exe and settings.ini into a folder, say, myfolder. Then copy the .wsi generated in step 1 above into myfolder. Then copy the dotnetfx.exe (the .net framework installer) into myfolder.
The dotnetfx.exe can be downloaded from here:
http://www.microsoft.com/downloads/details.aspx?FamilyId=D7158DEE-A83F-4E21-B05A-009D06457787&displaylang=en
All files in myfolder now constitute your new installation package. This installation will first check if .NET is installed or not on the target computer, if not, then it will silently install it and then it will install your application.
I hope this helps.
Suhas
Those who can, do, those who cannot, teach.
|
|
|
|
|
Visual studio .net Installer it’s an useful ( and free J ) tool to deploy for project, but... there is a problem, what if your client doesn’t have installed the “.net framework”, to make your application able to be installed on any machine, the guys from Microsoft made one sample, look at this in the msdn page:
Microsoft .NET Framework Setup.exe Bootstrapper Sample
|
|
|
|
|
say suppose i am working with few controls and in a control collection loop i want to show the each control name,caption and control type.if it is possible in c# then please tell me with sample code.
tbhattacharjee
|
|
|
|
|
foreach(Control c in this.Controls)
{
MssageBox.Show(c.GetType().ToString());
MssageBox.Show(c.Name);
}
Mazy
No sig. available now.
|
|
|
|
|
Say suppose i have five button on a form and i want to trap click event for all five button in single event procedure.how could i do it please explian me with code example...
tbhattacharjee
|
|
|
|
|
if I understand correctly you have 5 buttons on a form and regardless of which one the user clicks you want the same event handler to be fired.
There are a couple of ways of doing this and it all depends on what your personal coding preference is.
Method 1
Create your 5 buttons and then in code allocate the same handler to the event.
E.G.
this.button1.Click += new System.EventHandler(this.5buttonEvent_Click);
this.button2.Click += new System.EventHandler(this.5buttonEvent_Click);
this.button3.Click += new System.EventHandler(this.5buttonEvent_Click);
this.button4.Click += new System.EventHandler(this.5buttonEvent_Click);
this.button5.Click += new System.EventHandler(this.5buttonEvent_Click);
Method 2
Allocate different event handlers to each of the buttons, and in each event call the same piece of code
e.g.
private void button1_Click(object sender, System.EventArgs e)
{
DoEvent(sender, e)
}
private void button2_Click(object sender, System.EventArgs e)
{
DoEvent(sender, e)
}
Repeat for button3, 4 & 5
void DoEvent(object sender, System.EventArgs e)
{
}
There are probably a few other ways of doing this, I personally would go for method one as it uses less code.
|
|
|
|
|
I have installed IIS in my winXp,and i built a asp.net web service ,It compile Ok,but when run debug,It hint a error(It tool difcult for me to understand ) and I must disable debug,how i do to solve this problem?
|
|
|
|
|
I have a struct to mimic a c++ struct...I have converted types as follows:
C++ C#
---- ----
WORD ushort
DWORD uint
char[] string
the imported function passes a pointer to the struct, fills it with fun-facts and gives it back more useful than before. The only thing I currently want out of this is the char[] member of the struct and things are not working out.
Here's what I have done:
- I am using CharSet.Auto in the structLayout and dllImport attributes.
- in the function prototype : "ref STRUCTTYPE structname"
- before calling the function, initializing struct by using "new"
- before calling the function, initializing the string by creating a StringBuilder buffer of appropriate size and "ToString-ing" it to the struct.string member.
problem is, when I call the function and access the string, it still contains the text that I used to initialize it in the first place.
I haven't done enough testing to determine the problem, but I wanted to see if you have any ideas. My first question is to verify that using a c# string to represent the c++ char[] is all cool. I think it should be.
[Edit] Almost, need [MarshalAs(UnmanagedType.ByValTStr, SizeConst=256] because it is a fixed char array [/Edit]
What I was thinking of while typing right now, is this:
in c++ structs are reference variables. in c# they are value variables. if i wanted to pass a c# struct to a c++ function, i would use the ref modifyer. Since my function wants a pointer to the struct, should I be using something like "ref IntPtr structname" ???? is this my problem and my solution?
[Edit] not quite, should work with "ref STRUCTTYPE structname"... if the struct were represented using a class, then would need [In,Out] instead of ref. See link in next post for details. Can't wait to get home and try it![/Edit]
Tym!
|
|
|
|
|
|
How can I make a ListView editable?
The LabelEdit property doesn't work with columns, when I double click a subitem just edit the first subitem, not the one I actually double clicked.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
You need to create a tableSyle, something like this:
DataGridColumnStyle itm;
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = dsErrorDetails.Tables[0].TableName;
itm = new DataGridTextBoxColumn();
itm.Width = 120;
itm.NullText = "";
itm.HeaderText = "header"
itm.MappingName = dsTables[0].Columns[y].ColumnName;
itm.ReadOnly = false;
tableStyle.GridColumnStyles.Add(itm);
So, you create an "itm" for your particular column that you would like to be editable. And set the ReadOnly to false. Here is where you can also adjust the width, sort, etc. of the column.
Hope this helps...
|
|
|
|
|
hm.. is this for a ListView? It looks like you do this for a DataGrid?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Hi all.
I have written a very simple windows service where I have made overrides for OnStart, OnStop and OnShutdown. In the properties I have set CanStop and CanShutdown to true. The only thing that is to be done at the moment is that when either event is fired a line should be written to the log.
This works fine for OnStart and OnStop but it's like OnShutdown is never executed. Can anyone tell me what I'm doing wrong? This is my code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
namespace MyServiceTest
{
public class MyService : System.ServiceProcess.ServiceBase
{
private System.Diagnostics.EventLog eventLog1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public MyService()
{
// This call is required by the Windows.Forms Component Designer.
InitializeComponent();
//Create event log
if(!System.Diagnostics.EventLog.SourceExists("MyServiceLogSourse"))
System.Diagnostics.EventLog.CreateEventSource("MyServiceLogSourse","MyServiceLog");
//register name of source
eventLog1.Source = "MyServiceLogSourse";
eventLog1.Log="MyServiceLog";
}
// The main entry point for the process
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
// More than one user Service may run within the same process. To add
// another service to this process, change the following line to
// create a second service object. For example,
//
// ServicesToRun = New System.ServiceProcess.ServiceBase[] {new Service1(), new MySecondUserService()};
//
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new MyService() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.eventLog1 = new System.Diagnostics.EventLog();
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
//
// MyService
//
this.CanShutdown = true;
this.ServiceName = "MyService";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
/// <summary>
/// Set things in motion so your service can do its work.
/// </summary>
protected override void OnStart(string[] args)
{
// Write to log
eventLog1.WriteEntry("MyService starts");
}
/// <summary>
/// Stop this service.
/// </summary>
protected override void OnStop()
{
// Write to log
eventLog1.WriteEntry("MyService stops");
}
protected override void OnShutdown()
{
// Write to log
eventLog1.WriteEntry("MyService shutting down");
}
}
}
Thanks
/EnkelIk
|
|
|
|
|
Sorry, left out a bit of information there: OnStart and OnStop executes when I start and stop the service manually. When I restart the computer OnStart is the only method that executes (when the service is automatically restarted); I expected at least OnShutdown to execute to.
/EnkelIk
|
|
|
|
|
I have a problem with keyboard hooks - every time i press hold the CTRL+SHIFT key for quite some time, my application will crash with the error message :
"An unhandled exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object."
I've searched high and low for a solution to this matter but to no avail. Here's the code that i am using, it is meant to disable keys like ALT+TAB, CTRL+ESC, etc:
protected delegate int LowLevelKeyboardProcDelegate(int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam);
[ DllImport( "user32.dll", EntryPoint="SetWindowsHookExA", CharSet=CharSet.Ansi )]
protected static extern int SetWindowsHookEx(int idHook , LowLevelKeyboardProcDelegate lpfn, int hMod , int dwThreadId);
[ DllImport( "user32.dll")]
protected static extern int CallNextHookEx(int hHook,int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam);
[ DllImport("user32.dll")]
protected static extern int UnhookWindowsHookEx(long hhook);
const int WH_KEYBOARD_LL = 13;
public struct KBDLLHOOKSTRUCT
{
public int vkCode;
int scanCode;
public int flags;
int time;
int dwExtraInfo;
}
protected int intLLKey = 0;
protected int LowLevelKeyboardProc(int nCode,int wParam,ref KBDLLHOOKSTRUCT lParam)
{
bool blnEat = false;
switch (wParam)
{
case 256:
case 257:
case 260:
case 261:
//Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key
if (((lParam.vkCode == 9) && (lParam.flags == 32))
|| ((lParam.vkCode == 27) && (lParam.flags == 32))
|| ((lParam.vkCode == 27) && (lParam.flags == 0))
|| ((lParam.vkCode == 91) && (lParam.flags == 1))
|| ((lParam.vkCode == 92) && (lParam.flags == 1))
|| ((true) && (lParam.flags == 32)))
{
blnEat = true;
}
break;
}
if (blnEat)
return 1;
else
{
return CallNextHookEx(0, nCode, wParam, ref lParam);
}
}
public void KeyboardHook()
{
intLLKey = SetWindowsHookEx(WH_KEYBOARD_LL, new LowLevelKeyboardProcDelegate(LowLevelKeyboardProc), System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]).ToInt32(),0);
}
|
|
|
|
|
Sir
i write a code in C#
char myChar='/u0634';
Console.WriteLine("Unicode Character is {0}",myChar);
but it not give the actual character of that unicode.
what's the problem pls any tell me.
Thanks in Advance.
|
|
|
|
|
Hi!
Console automaticaly convert string to OEM encoding and then type it in console window...
that is why not all unicode charecters can be converted and shown in console window.
try to do the same on WindowForm...
Good Luck
Alex Kucherenko
|
|
|
|
|
I have two ListViews, DataGrids whatever, and they both contain data from 2 seperate datasets. I'd like to have a scrollbar on one view that when scrolled would automatically adjust the other view so they both stay in sync. Both datasets would contain the same number of rows. Can this be done with C#.NET?
Fairly easily?
Any help/sample code would be greatly appriciated!
Thanks
|
|
|
|
|
C#, at least I think, is alot better than vc++6 since everything is soo easy to use and soo powerful.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
So, you're saying that VB is better than C++?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
I'm not saying that since I myself is a c++ proggrammer. It's just that it is said that C# combines the power of c++ with the ease of vb, though I know that C# has some issues, I think that this will probably erase mfc and visual c++ 6 though it will be alive, it won't be the preffered language anymore, just wait a couple of years and you'll see how it will progress.
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Snyp wrote:
I think that this will probably erase mfc and visual c++ 6 though it will be alive, it won't be the preffered language anymore, just wait a couple of years and you'll see how it will progress.
It will do progress, but will not erase C++, ever!
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
GRR... I didn't say that it will KILL C++, I said that it won't be the preferred language...;)
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Whatever, dude!
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|