|
I can't believe how many people ask this. If the .NET framework was not needed, why would we install it at all ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Because we install Mono instead?
|
|
|
|
|
|
How to create text file & update the same with events in code behind?
if anybody worked on this plz send me soon
Harish
|
|
|
|
|
i've worked on creating an execution trace log. If this is what your are looking for, then may help you.
(this is in vb.net)
-------------------------------------------
Imports System.Configuration
Imports System.IO
Module LogWriter
Dim LogWriter As TextWriter
Dim LogPathFile As String = ConfigurationSettings.AppSettings("logPath") & "ExecutionTrace.log"
Public Sub WriteLog(ByVal strLogTxt As String)
Static ExecFirstTime As Boolean = True
If File.Exists(LogPathFile) Then
LogWriter = File.AppendText(LogPathFile)
Else
LogWriter = File.CreateText(LogPathFile)
End If
strLogTxt = Now.ToLongTimeString & " " & strLogTxt
LogWriter.WriteLine(strLogTxt)
LogWriter.Close()
End Sub
-----------------------------------------------
|
|
|
|
|
Hi,
I´m trying to load an assembly at runtime with:
ObjectHandle plugin = System.Activator.CreateInstanceFrom(@"C:\PathToDll\MyDll.dll", "PluginClass");
But this returns a strange error:
Exception has been thrown by the target of an invocation.
"The targetNamespace parameter 'MyDll' should be the same value as the targetNamespace 'urn:MyDll' of the schema."
ok, where does a schema come into the picture?
All help would be appreciated.
|
|
|
|
|
I think that would imply that you need to specify the namespace in the class type field and it should match the DLL name, so try:
ObjectHandle plugin = System.Activator.CreateInstanceFrom(@"C:\PathToDll\MyDll.dll", "MyDll.PluginClass");<br />
Hope that helps!
|
|
|
|
|
|
Currently, my server DLL just runs locally without remoting logic, and when I want to read and save a UserAccount class I just pass the class back and forth as is. I use binary serialization to save and read the UserAccount class. I want to do 2 things now.
1) Make the server DLL run remotely as a client activated object.
2) Encrypt the UserAccount and other data passed to the server (like the password).
I would like to know what a best practice would be for #2. I am thinking that I would serialize the UserAccount to a memory stream and then encrypt that data before sending it to/from the server. The receiving side would un-encrypt it and deserialize it back into a UserAccount object.
Currently, my application is a Windows Forms one, but I will eventually learn ASP .NET and make it into a web app. So, I would like to come up with a solution now that would also work with a web app, if possible. I am doing all of this to learn C# and .NET. I don't know SQL or ADO yet, and am wondering if my suggested solution is a good one, or if a real programmer .NET pro would do it differently.
Thanks!
|
|
|
|
|
I am using Managed C++ (not C++/CLI) with VS .NET 2003 and .NET framework 1.1.
I have a DataGrid on one of my forms, and I override the MouseUp event so that when the user clicks on a cell, it highlights the entire row:
System::Void datagrid_MouseUp(System::Object* sender, System::Windows::Forms::MouseEventArgs* e)
{
using System::Drawing::Point;
using System::Windows::Forms::DataGrid;
using System::Windows::Forms::DataGridCell;
Point pt = Point(e->X, e->Y);
DataGrid* datagrid = __try_cast<DataGrid*>(sender);
DataGrid::HitTestInfo* hti = datagrid->HitTest(pt);
if (hti->Type == DataGrid::HitTestType::Cell) {
datagrid->CurrentCell = DataGridCell(hti->Row, hti->Column);
datagrid->Select(hti->Row);
}
else {
}
} However, now my DataGrid will not sort when clicking on one of the header columns. My guess is that since a column header is not a cell, then this event handler says to do nothing; therefore, I need to add code in the else block to tell it to sort if it is a column header. How do I do this? I would rather not have to derive my own class from DataGrid if possible.
--
Marcus Kwok
|
|
|
|
|
Is anyone aware of how to dynamically resize specific item font sizes in a list control?
basically i want to be able to increase the size of the font for the selected item only.
Any help would be greatly received.
Tom
|
|
|
|
|
tom_barber wrote: in a list control?
to confirm ideally a ListBox control
|
|
|
|
|
There's no built-in way to do it. You'd have to ownerdraw each item in the ListBox yourself and, in your painting code, determine how you wanted to paint each item in the list. At least that's how'd you do it in the full .NET Framework. I have no idea if it's possible in the CF.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm having a little problem with some unit tests. I have a project that has some files that get copied to the bin folder. Each file has a build action of "Content" and Copy To Output Directory of "Copy Always".
So far so good. Even the projects that are dependent on the project with the files get the files copied to their bin directory. That is perfect - exactly what I want.
However, if I run a unit test, VSTS creates a directory to run the tests in. (Fair enough - good to keep the tests in isolation) The directory looks like this:
C:\<solution folder>\TestResults\<username>_<machine> <datetime>\Out
The parts in angle brackets depend on where, when and who is running the test so the directory structure is unknown (and doesn't exist) at build time. (It creates a new folder for each test run)
The problem is that it does not copy in the additional files I need, just the assemblies and the pdb files. So when the code attempts to load one of the files it fails because it doesn't exist.
Does anyone have any ideas for getting the files to get copied into the correct folder? (i.e. the one with all the assemblies)
|
|
|
|
|
Double clicking the .testrunconfig opens up a dialog that allows you to add additional files to the directory (click Deployment in the dialog)
|
|
|
|
|
Thanks - I've got it working now!
|
|
|
|
|
Hi all...I am a novice in reports so if my question is stupid please let me know..I am working on an OMR application.I want to print an OMR sheet.I want the users to customize the sheet by selecting no of Questions and no of options.I am thinking about using a report to print the sheet.So my question is how could i make a report programatically by supplying the no of columns and rows...Is there any other alternative..Please help me folks as i am stuck..!
|
|
|
|
|
Is there anything available that will automatically take care of the < > & ' and " chars in a string upon adding it to an attribute in an XML node?
I don't have a problem with creating a function that escapes and unescapes the text in my class but kind if figured that this might be something that is already in there and I am just missing it.
I am looking around (have been for about 30 minutes so far) and am not finding anything so I thought I would ask. Usually Google gets me there pretty quick if it exists.
|
|
|
|
|
If you use the XML DOM classes it does do it for you.
using System;
using System.Xml;
class Example
{
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
XmlElement root = doc.CreateElement("root");
doc.AppendChild(root);
XmlElement child = doc.CreateElement("child");
root.AppendChild(child);
XmlAttribute attr = doc.CreateAttribute("example");
attr.Value = "<CodeProject ©>";
child.Attributes.Append(attr);
doc.Save(Console.Out);
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
You could always do this by using HttpUtility.HtmlEncode on the text. This converts the characters that Html doesn't understand into ones that it does, e.g. & becomes &.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have a problem with a Windows Forms project I am toying with. I am creating a quicken like program. The main window creates a MDI child for each account (checking, credit card, and broker). I cannot figure out how to handle the close button. I want the form to just hide itself and remain in the main menu item that I dedicated to keeping the names of the children, so that the user can reselect and open the form again. However, this doesn't work:
private void CheckingAccountForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
this.Visible = false;
e.Cancel = true;
}
}
The window is removed from the menu, and I currently have no way to bring it back.
Ideally I would like to remove the close button from the header of the form but leave the other two. I can't see any way to get rid of that button without losing the others.
I may just get rid of the header and add two custom buttons for the other two functions (minimize and full/screen toggle).
Any ideas?
Another pesky problem is that if I click the close button on the main form, it closes the children but stays open, and I gotta click the close buttong again.
Thx.
|
|
|
|
|
I think you'll have to roll your own MDI window list if you want it to show hidden forms.
You can probably remove the close button from the child forms by using P/Invoke. I wouldn't though nor would I suggest you implement your own buttons for minimize and maximize. People expect those buttons to be there if the function can be done.
You must be doing something somewhere to prevent the closing. I put together a quick MDI application that maintains a window list, creates children, and hides children instead of closing them when requested (although I overrode the OnFormClosing method instead of creating an event handler).
|
|
|
|
|
Thanks. I did end up adding my own combobox to my toolstrip. I found that the way I am handling the form_closing event works, in that it keeps the MDI window in the parent's mdiChildren list. So, by setting the e.Cancel to true, the child stays in the list, but setting Visible to false causes it to be removed from the menu item.
|
|
|
|
|
I wrote a routine using some of the reflection features to look for paired member fields in a class. The function looks up this variable's value and the value of the paired variable, which may or may not actually exist. If it does, then its boolean value is read, and if true the function returns a System.DBNull.value, otherwise the function just returns the value of the named field passed into it when called.
Rather than use variant variables to store my database fields, I'm using two fields to store the value read from a database. The first is a typed field variable for the actual data, if it's not Null, and the second is a boolean to track if the database value was Null or not, i.e., Name and Name_Is_Null, both of which belong to an instance of the DataBase_Info class.
Currently, the function is called with a string containing the name of one of the member fields, and there is only one instance of DataBase_Info. Now I'd like to pass the actual field variable to the function, and have resolve the class instance, if there is a paired member, and return either the value passed in if their isn't a paired member or it's false, otherwise return System.DBNull.value. How can I resolve the name of a variable passed in as a parameter and its container at run-time?
Thank you
|
|
|
|
|
Rather than writing your own mechanism, why not just use strongly typed data sets, which do this all for you? They're easy to create, very robust, and with .NET 2.0 very flexible to change the underlying connection and fetch behaviors. Take a look at many of the search results on MSDN from http://search.msdn.microsoft.com/search/default.aspx?siteId=0&tab=0&query=strongly+typed+dataset[^].
As far as answering your question, you can use Type.Method or Type.GetMethods . With each MethodInfo , you can call MethodInfo.GetParameters . There are also other interesting and pertinent properties on MemberInfo you may need to pay attention to, like IsGenericMethod . Just depends on what methods you're reflecting and how they're written.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|