|
This will create a new login form object (assuming you called it 'frmLogin') and show the form as a modal dialog with your main form as it's owner (referref to as 'this').
frmLogin LoginForm = new frmLogin();
LoginForm.ShowDialog(this);
RageInTheMachine9532
|
|
|
|
|
Hi,
i have next class :
public class abc
{
public string campo 1;
public string campo 2;
public Socket CltSckt;
public NetWorkStream NS;
}
After of initialize the class and stored the data for each variable, I wish to send or store in a Queue :
public int EscribeCola(string SrvName, string QueueName, abc Msg_Devices)
{
try
{
MessageQueue msgq = new MessageQueue();
msgq.Formatter = new XmlMessageFormatter(new Type[] {typeof(string)});
System.Messaging.Message msg = new System.Messaging.Message();
msgq.Path = (SrvName + QueueName);
//
// coloco el mensaje en la cola
lock(this)
{
msgq.Send(Mensaje_Devices);
}
msgq.Dispose();
return 0;
}
catch (Exception ex)
{
acc_evento.ReportaEvento(PROCESO_ORIGEN,Param_Eventos.PROBLEMA_WRITE_QUEUE, QueueName + " " +
ex.Message + " " + ex.InnerException.Message);
return -1;
}
}
In the moment of "send", present a runtime error :
"There was an error refecting 'Msg_Devices'"
"System.net.sockets.socket"
"Cannot be serialized because it does not have a default constructor".
May you help me?
What have I do?
Grettings
|
|
|
|
|
It's indicating that you can't serialize the Socket object, looks like to me; not only does it not have a default constructor, but it doesn't implement the ISerializable interface isn't marked with the SerializableAttribute attribute. What would be the value in serializing a socket, anyway? You can mark it with the [NonSerialized] attribute to avoid this problem.
Regards,
Jeff Varszegi
EEEP! An Extensible Expression Evaluation Package
|
|
|
|
|
To note, something doesn't have to implement ISerializable to be serializable - only to be attributed with the SerializableAttribute (not inheritted with the formatters provided in the FCL, as it should be). The interface is just to customize how an object is serialized. You're still right about the Socket class not being serializable, though. I mean, that's just silly!
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Whoops, right you are. My Java undies are showing-- in Java the Serializable interface is just a marker interface, with Externalizable the one you implement to provide your own serialization routine. I get mixed up sometimes because some things are so similar in Java and .NET, and I still have to use both at work. I'm getting used to rapidly switching between naming and casing conventions, but the APIs still trip me up occasionally. Thanks for the correction.
Regards,
Jeff Varszegi
EEEP! An Extensible Expression Evaluation Package
|
|
|
|
|
I tried to put [NonSerialized] the class, but show me a compilation error.
Please, may you send me an example?
|
|
|
|
|
Don't put it on the class, just on the fields you don't want to serialize, like so:
<br />
public class abc<br />
{<br />
public string campo 1;<br />
public string campo 2;<br />
<br />
[NonSerialized]<br />
public Socket CltSckt; <br />
<br />
public NetWorkStream NS;<br />
}<br />
Try that and get back to me.
-Jeff
here, bloggy bloggy
|
|
|
|
|
I have written an add-in for Outlook which adds a button to the toolbar.
It works great and now I'm trying to tweak it. I cannot for the life of me figure out how to set the icon next to the text. I've tried several suggestions I've seen on the net to no avail.
Keep in mind that there is no form for the plug-in that is loaded until AFTER you press the button.
Note: The project is actually written in VB. Why in the world would I post in the C# forum? Because all the good people are now using C#. If you don't know the VB equivalent code, no big deal I can read C# well enough.
Also, what distribution files need to be included (other than the 1.1 framework)? It installs great on my two machines running power point 2003 and power point 2000. However, both machiens have the development environment already on them. I sent my manager the .msi and he installed and says the button is not there. So I'm guessing some dependancy is missing.
--Tony Archer
"I can build it good, fast and cheap. Pick any two."
|
|
|
|
|
You have to deploy the interop assemblies too, like Microsoft.Office.Interop.Outlook.dll. These need to either be installed into the Global Assembly Cache (GAC) or into the installation directory of your application (or in a sub-directory configured as a probing path).
It doesn't matter if your form is loaded or not - your add-in is still loaded otherwise you'd see no command button at all. Also, if you're using Office 2003 Smart Documents and its interop assemblies, you MUST add a code-group to the machine policy that points to your assembly, even if running under the local machine. Office 2003 includes a CLR host that works differently than the executable loader in Windows.
Finally, there's plenty of information about Office solutions development in MSDN, such as Custom Button Faces in a Managed Code Add-in for the Microsoft Office System[^]. The same should work for older interop assemblies that work with older versions of Office which almost always work completely with newer versions of Office (it's all about versioning interfaces in COM).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath, You absolutely ROCK!
It was actually the C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Office.dll
that was missing. I sent it to my boss, he put it into the install dir for the project and POOF everything worked.
Guess I have to manually set copy local to true. I would have thought that VS would recognize if something is not a standard Framework file (as VB6 does with com components) Oh well, that won't happen to me again.
Reading that article you linked me to now. Looks promising. Thanks!
--Tony Archer
"I can build it good, fast and cheap. Pick any two."
|
|
|
|
|
Files like that should actually be installed into the Global Assembly Cache (GAC), though, since they are common to many applications (potentially). The GAC also provides versioning support if a new one is ever installed, so that your application will continue to use the older version (since the new one isn't just copied over it - known as DLL hell) unless you used a publisher policy or assemblyBinding section in the .config file.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have an XmlDocument object that I've constructed in memory.
I'd now like to display the contents in a System.Windows.Forms.TextBox.
What is the best practise for converting the XmlDocument to a string so that it can be displayed in a TextBox with the whitespace formatting intact?
Michael
CP Blog [^]
|
|
|
|
|
I'd use doc.Save(StringWriter), followed by Textbox1.Text = StringWriter.ToString()
(don't forget to call Dispose on the StringWriter).
Due to technical difficulties my previous signature, "I see dumb people" will be off until further notice. Too many people were thinking I was talking about them...
|
|
|
|
|
Does anyone know how to convert Unix time (seconds since Jan 1, 1970)
to a C# DateTime object??
TIA,
Matt
|
|
|
|
|
DateTime represents the time since 00:00:00 Jan. 01, 0001 AD. Do the math.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
Do the math.
1 second
2 seconds
3 seconds
4 seconds
5 seconds
6 seconds
7 seconds
8 seconds
9 seconds
10 seconds
Damn I ran out of fingers, where was I again...?
|
|
|
|
|
Hi, im making a custom control inherited from System.Windows.ListView. I would like to add a filters to its columns and others features to work with datatables y detalis view.
Its possible to add a textbox control to an columnheader or to and items of lisview?
Can I only had fiters using System.Runtime.InteropServices messages overrating winproc way?
How can I capture keypress, keyup, or keydow of filters of lisview (System.Runtime.InteropServices messages overrating winproc (IE))
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
You're writing a custom ListView and you have no ideas about any of this stuff?! You should read some of the articles on this site, such as the ListViewFilter Control for .NET[^].
The ListView already has events for the keyboard. If you're looking for information on all the messages, see the Platform SDK in the Common Controls section for the List-View common control reference.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you, in this moment i have my custom control in this way (using your tips) adding at run time textbox for each colum in listview and works fine, usinf the keyup event (enter key) of textbox for make the filter. But this has a problem when the colums are bigger than the lisviww.width or resize the column.width. For that I try changing the size of textbox at the time when the column do it and work fine. Or making the colums fixed.
Then Found ListViewFilter a see the columns whit nice filters, but coulnt find to capture the event keyup of these filters only texchange an click the button of the filter.
In other hand i would like no use the interop with windows dll because i don want to take mi code with only .net and in the future use it in diferent plataforms.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
machocr wrote:
In other hand i would like no use the interop with windows dll because i don want to take mi code with only .net and in the future use it in diferent plataforms.
Right there you have a problem that you really need to understand. Almost every control in System.Windows.Forms encapsulates a native common control and by using messages they're already not portable (sort of). Ports like Mono/GTK to provide the same public and protected methods of classes but they implement them in a different way. Open source platforms like linux don't use a messaging system like Windows so overriding WndProc even for something simple will not work. Your custom control is already not portable.
Use what works - like the ListViewFilter I linked for you - and get it to work on Windows. Writing portable apps limits what you can do, and you need to understand how all that works.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm pretty new to C#. I have downloaded the bootstrapping sample and am having trouble getting it to work. I have placed the setup.exe file and the settings.ini file in the same folder as the .msi file. Here is my modified settings.ini file.
[Bootstrap]
Msi= Hydrolog Setup.msi
'LanguageDirectory=
'ProductName= Hydrolog
'DialogText=
'CaptionText=
'ErrorCaptionText=
'FxInstallerPath= c:\
When I start setup.exe I get a MessageBox that says "To start Application Setup, click OK. To quit without installing, click Cancel." When I click on the OK button I then get another MessageBox that says incorrect command line parameters.
Am I not doing something? Can someone help me out?
|
|
|
|
|
You realize "bootstrapper" is a generic term, don't you? What bootstrapper are you talking about? If it's one on the CodeProject site, then ask in the article's message board at the bottom. Those message boards are for specific questions / comments regarding the article.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I was referring to the bootstrapper example that is on the Microsoft website. http://www.microsoft.com/downloads/details.aspx?FamilyID=bf253cfd-1efc-4fc5-ba7e-6a6f21403495&DisplayLang=en
|
|
|
|
|
Try putting the .MSI file in quotes since it includes spaces. This is common. Also, if you're set other properties you need to remove the comment character ' . There is documentation[^] that you should read.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Got it to work!! Thanks for the help. The Probelem was the name of my msi file. I changed it to one word and it worked.
|
|
|
|