Whenever I share files between projects it appears that Visual Studio.NET copies the files over into the new project. I want to just share the file and not have it copied over. Is there any way to do this
When you add an existing item from with the Visual Studio.NET IDE, click the small arrow on the ’Open’ button in the dialog that is presented. You will see a list of options. One of these is to ’Link file’. If you select this option then you will not get a local copy and any changes that you make to the linked file will be in the original file. Another way to get the same effect is to share the files using Visual Source Safe. You can simply drag and drop the files between projects in VSS and they will also be in sync.
How do I use an exported function (extern ‘C’) from a legacy DLL
Use the DllImport attribute that is a member of the System.Runtime.InteropServices namespace. Assume your exported function found in MyDLL.dll has a signature: int MyFunction( LPCTSTR lpCaption, UINT uType); The code below shows how you can access this function from within C#. using System; using System.Runtime.InteropServices; class HelloWorld { [DllImport(‘mydll.dll’)] public int MyFunction(string title, int type); public static void Main() { int nReturnValue = MyFunction(‘some string’, 14); } }
How can I implement VS.NET type menus
Carlos Perez provides sample code at codeproject.com.
How can I get text from a column header in a MouseUp event
private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { System.Drawing.Point pt = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt); if(hti.Type == DataGrid.HitTestType.Cell) { MessageBox.Show(dataGrid1[hti.Row, hti.Column].ToString()); } else if(hti.Type == DataGrid.HitTestType.ColumnHeader) { MessageBox.Show(((DataView) DataGrid1.DataSource).Table.Columns[hti.Column].ToString()); } }
How can I direct debug output to a text file
You need to add a Trace Listener to your code. Below is sample code that adds a TextWriterTraceListener (and don’t forget the Flush before you terminate). For more information on tracing in general, look for the topic ‘Tracing Code in an Application’ in your online .NET documentation. //set up the listener… System.IO.FileStream myTraceLog = new System.IO.FileStream(@’C:\myTraceLog.txt’, System.IO.FileMode.OpenOrCreate); TextWriterTraceListener myListener = new TextWriterTraceListener(myTraceLog); ………. //output to the instance of your listener myListener.WriteLine( ‘This is some good stuff’); ……….. //flush any open output before termination… maybe in an override of your form’s OnClosed myListener.Flush();