|
I shoulda known to stay out of it as soon as I saw J#.
And serialization [i]will[/i] serialize reference pointers instead of the objects they point to in some situations unless you explicitly override the serialization methods.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
|
|
|
|
|
I'd be interested to know what situations those are. We've used both SOAP and binary formatting (runtime serialization) in our massive N-tier application I primarily architected and objects to which member fields reference (and what not) are serialized. This is especially true for SOAP where even a byte offset for a child object isn't possible.
In any case, the J# libraries work differently from the .NET FCL and to be honest, I'm really not sure about all that. It's basically a port of the JRE. I answered a question not long ago about java.util.Date . Someone for some reason thought that you could simply cast a DateTime to a Date . Not only wasn't that possible, but they use different epochs (which I remember from Java years and because of a couple recent projects interop'ing Java and .NET at the presentation layer that I developed a couple years ago).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've never run into it personally, but I read a forum message (on gotdotnet.com, IIRC) where a guy was serializing an object with SerializableAttribute, and not implementing ISerializable or providing a serialization constructor.
Problem was, the default serialization mechanism would serialize the function pointers assigned to any events. When he deserialized, the pointers were invalid, and caused all sorts of problems.
His actual issue in the post was that the NonSerializableAttribute applies to fields only, and not to events.
This was awhile ago, though. The default serialization functionality may have changed in 1.1 to not serialize event function pointers.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
|
|
|
|
|
I see. That would make sense regarding delegates (event handlers). For fields, however, this shouldn't be a problem.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is it possible to have a J# client and a Java server and send objects between them?
As it seems now our J# client only seems to handle all objects it gets from the Java server as Strings.
Just wondering if we must throw in the Server in the .NET environment or if we have made some other mistake.
|
|
|
|
|
I need a class that can be seen by multiple running exe's, but have only one instance running. The first program exe that opens will fire up the dll and all others after than will just use it.
I want to use this for a licensing situation. We have several front-end exe's that I want to do licensing for. The dll is going to communicate with a licensing server every few mins. If the server goes down, I want the dll to show a warning and close all exe's attached to it after a few mins.
I've never had to do anything like this before in c# and am looking for a couple of good ideas. I don't necessarily have to use the dll idea either. As long has I can attach a couple of exe's to the same instance of something in memory and catch a close event or message from it, it should work.
Another bad point is that all the exe’s aren’t in .net yet. Some are legacy vb6 still. I don’t know what problems this will entail, but the ideal solution would close them also.
I have evaluated several licensing packages and haven’t found one that will do what I want. The ones I can afford won’t and the ones that will do licensing per company are hugely expensive, so I think we have to roll our own.
If I could find a licensing package for under around 5K that would probably work also. We looked at flex LM but it’s ridiculously expensive. It would do the per company license scheme we want. (Company a buys 10 licenses, company b 100 etc. A can have 10 computers running my software at one instance in time (as many computers installed, just 10 running at one time), b 100 etc.)
Sorry for rambling here
If you need any other info or clarification let me know.
TIA
|
|
|
|
|
DLLs - be they native libraries or .NET assemblies - are always loaded into the process space. This is how execution works.
If you want a singleton pattern in .NET, you can use a well-known singleton object using .NET Remoting. A good place to host this would be in a Windows Service (see ServiceBase ).
If your applications aren't all .NET applications, this is definitely a problem.
One thing you might consider is writing a COM+ object with singleton activation. This would make the object available to .NET and native applications, although using it in native applications is a little more difficult. You can read more about COM+ - including how to use it with the .NET Framework - by reading COM+ (Component Services)[^] in the MSDN Library online. You should also read Writing Serviced Components[^] in the .NET Framework and follow the links to class documentation to learn more. You could write this component service in .NET in such a way that it would work for both managed and unmanaged (native) applications and when those latter applications are converted to .NET (if they will be) switch over to .NET Remoting if you like (you would have to, though - it's just a little easier to deploy). This means abstracting the actual licensing code away from the component so that it could be used by either a serviced component or a .NET Remoting object.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the info. I've done several services and a com+ service object. I'll check into using something like that.
|
|
|
|
|
Sorry if this has been asked before: i have a class that i want to move across the network as xml. using the xmlserializer class converts the class to xml however there is some data produced in the final xml that i would rather not have, for example, the first line <?xml yada yada yada ?> i don't need for my purposes and would rather not have this automatically produced. Can i prevent the xmlserializer class from inserting this first line? Also the class that is being serialized to xml ends up with some schema data which again, i don't need for my purposes, Example::
<?xml version="1.0" encoding="utf-16"?>
<OrderRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Control>2.0</Control>
<Header>
<SenderID>1123123</SenderID>
<ReceiverID>39393</ReceiverID>
</Header>
</OrderRequest>
so basically i want the output from the serialization to be like this:
<OrderRequest>
<Control>2.0</Control>
<Header>
<SenderID>1123123</SenderID>
<ReceiverID>9393939</ReceiverID>
</Header>
</OrderRequest>
any help advice is greatly appreciated!!
|
|
|
|
|
The first line is there for a good reason: it tells the other end what version of XML your file is in and what the encoding is. You really shouldn't delete it. It won't affect any XML classes (like an XmlTextReader ) on the other end.
Simply using the XmlSerializer , there is no way to remove the processing instruction. If you want to do it anyway (and again I strongly recommend against it - it's not like it's hurting anythig anyway), you'd have to serialize your object graph to a stream (perhaps a MemoryStream ), read it back in using a combination of an XmlTextReader and an XmlTextWriter - or use an XmlDocument which can be slow depending on the size of the XML document/fragment - and remove the processing instruction before sending.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
yes i appreciate that information is there for a reason, however, the objects i'm building are simply to organise all the information and insure the end xml is properly formated (according to the receivers format). the receiver is not using .net and i'm not really sure how they are dissecting this xml document.
i'll try your idea and see if i get anywhere. thanks!
|
|
|
|
|
So long as the receiver is XML-conformant it will either utilitize the processing instructions or ignore them. Processing instructions are part of the XML specifications. Why don't you just try it and see? If it doesn't work, you might consider a better XML parser on the receiving end since it wouldn't truly be XML-conformant. Processing instructions are not Microsoft-specific.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
according to them (just phoned) they are and anything not in their specification is ignored. wooohooo. that just saved me hours of typing thanks
|
|
|
|
|
wookie wrote:
the receiver is not using .net and i'm not really sure how they are dissecting this xml document.
If you're not sure, then leave it in. It will actually HELP the receiver to decode the document because your supplying the specific XML version and encoding information. Leaving this out can cause problems between differing systems. Supplying too much information, in this case, is a good thing!
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
ok - in it stays.... thanks!
|
|
|
|
|
can i convert a field to checkbox in sql reporting service report how?
|
|
|
|
|
I need to import data from a DBase file in my C# application, but I'm not familiar with the .NET database stuff - can anyone point me in the direction of an article or some sample code?
|
|
|
|
|
Through
System.Data.ODBC namespace.
You could download it from Microsoft. Not sure it they had incorporated it into VS.NET or not.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
please visit this link
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbc_part_2.asp
Sreejith S S Nair
|
|
|
|
|
I've got the ODBC namespace, but I don't know what provider string to give when opening the connection to access a DBase file, and then how to actually access the data once I've opened it. There are plenty of examples for SQL, Oracle etc. but nothing specifically for the old DBase/FoxPro format.
|
|
|
|
|
ADO.NET is an abstraction layer. While various databases and other files that have OLE DB providers support different things, the basic things should be supported.
If you're not familiar with ADO.NEt, I suggest you read about it first. See Accessing Data with ADO.NEt[^] in the .NET Framework SDK.
Also, the ODBC ADO.NET provider (in the System.Data.Odbc namespace) is included in .NET 1.1 which means it's part of Visual Studio .NET 2003. It was only a beta in .NET 1.0. Same goes for the OracleClient . The SqlClient and OleDb namespaces have been available since .NET 1.0.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
If you have VB6. You can try in your IDE using the ADO object to connect to ODBC via connection string. Through the wizard provided by VB6. You could get the needed connection string. I am sure that there are easier way to do it which probably just a matter of few search in the net. The format are standard by the way, you should be able to figure it out. Sorry that I could not think it out off the hand.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Thanks for your help - I've sorted out the connection string ("Provider=Microsoft dBase Driver (*.dbf)};DSN=<filename>"), but I'm now stuck on the SQL string when I try to create the reader object - it should be something like "SELECT * from " but there doesn't appear to be a table name in the .dbf file. I've tried things like "SELECT * from *" but it doesn't like it. Any ideas?
|
|
|
|
|
How do you open a file for example an XML file in coding? I tried "File.Open(Path including filename,FileMode.Open,FileAccess.Read)" but it does not seem to work. Am I missing something?
Sweet
|
|
|
|
|
I usually go for something like this:-
XmlTextReader reader = new XmlTextReader(file)
and then read it with:-
while (!reader.EOF)
{
if(reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "AnInterestingNode":
// do stuff
break;
}
}
reader.Read() // advances the reader
}
The only thing to look out for is if you use reader.ReadOuterXML(); in a case statemant as this advances the reader, and the 'reader.Read();' call means you will miss a node. (This very thing has me scratching my head for about an hour!)
|
|
|
|