|
No problem, I'm glad i could help (and now i wish someone could answer my thread >_<)
|
|
|
|
|
Hi,
I'm currently stuck with the following problem:
<br />
<br />
XmlSerializer tSer = new XmlSerializer(typeof(Int16[]);<br />
<br />
This generates an FileNotFound error. It's obviously an problem whith the OnTheFly generation of the serializer dlls and happens with each Array declaration at the moment. I found some stuff on the net dealing with this, but no real solution for my problem. I tried to track it down with the XMLPreCompiler, but until now with no success.
The funny thing is, that this error seems only to happen on the first stage, as the array occurs in the written XML file.
Does anybody have a clue, how to deal with Arrays and the .Net 2.0 XMLSerializer ?
Thanks in advance,
Florian
|
|
|
|
|
Florian Storck wrote: I'm currently stuck with the following problem:
I don't get that problem at all with that instantiation. It just returns an XmlSerializer object.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hi Marc,
do you use .Net 2.0 ? Can you post a code example ? Maybe there are some prerequisites in my project causing this error.
Thanks,
Florian
|
|
|
|
|
Yes. .NET 2.0
Here's the little test app I wrote:
using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace XmlSerializerTest
{
class Program
{
static void Main(string[] args)
{
XmlSerializer ser = new XmlSerializer(typeof(Int16[]));
TextWriter writer = new StreamWriter("foo.xml");
Int16[] iArray = new Int16[] { 1, 2, 3, 4 };
ser.Serialize(writer, iArray);
writer.Close();
}
}
}
and it generates:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfShort xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<short>1</short>
<short>2</short>
<short>3</short>
<short>4</short>
</ArrayOfShort>
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hi,
I tried it in an completely empty project, and it doesn't happen there. So there seem to be some project dependencies...looks like I have to track it down there..
Florian
|
|
|
|
|
Florian Storck wrote: looks like I have to track it down there..
Walk through the inner exceptions. That often reveals the real reason for the serializer to die.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hello Marc,
some other strange thing is, that the VisualStudio catches the Exception, but I don't get the Exception in my own exception handler. Even if I switch off all Exception in Debug->Exceptions in VS, the Exception handler isn't called.
<br />
if (m_dicXmlSerCache.ContainsKey(TObj))<br />
{<br />
m_dicCacheHits[TObj]++;
return m_dicXmlSerCache[TObj];<br />
}<br />
else<br />
{<br />
XmlSerializer tSer = new XmlSerializer(TObj);<br />
m_dicXmlSerCache.Add(TObj, tSer);<br />
<br />
m_dicCacheHits.Add(TObj, 1);<br />
<br />
tSer.UnknownAttribute += new XmlAttributeEventHandler(XML_UnknownAttribute);<br />
tSer.UnknownElement += new XmlElementEventHandler(XML_UnknownElement);<br />
tSer.UnknownNode += new XmlNodeEventHandler(XML_UnknownNode);<br />
tSer.UnreferencedObject += new UnreferencedObjectEventHandler(XML_UnreferencedObject);<br />
return tSer;<br />
}<br />
}<br />
catch (Exception e)<br />
{<br />
m_Log.ErrorFormat("Error in SerializerCache: {0}", e.Message);<br />
}<br />
For explanation:
This Code acts as a cache for various serializer objects, to avoid unnecessary instantiations.
I've no real idea, why also my exception handler doesn't work here...
Bye,
Florian
|
|
|
|
|
Where's the try?
Anyways, I get the impression that the exception is happening in one of your tSer event handlers. Do you have try-catch blocks in the handlers?
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Oops,
<br />
try<br />
{<br />
if (m_dicXmlSerCache.ContainsKey(TObj))<br />
{<br />
m_dicCacheHits[TObj]++;
return m_dicXmlSerCache[TObj];<br />
}<br />
else<br />
{<br />
XmlSerializer tSer = new XmlSerializer(TObj);<br />
m_dicXmlSerCache.Add(TObj, tSer);<br />
<br />
m_dicCacheHits.Add(TObj, 1);<br />
<br />
tSer.UnknownAttribute += new XmlAttributeEventHandler(XML_UnknownAttribute);<br />
tSer.UnknownElement += new XmlElementEventHandler(XML_UnknownElement);<br />
tSer.UnknownNode += new XmlNodeEventHandler(XML_UnknownNode);<br />
tSer.UnreferencedObject += new UnreferencedObjectEventHandler(XML_UnreferencedObject);<br />
return tSer;<br />
}<br />
}<br />
catch (Exception e) <br />
{<br />
m_Log.ErrorFormat("Error in SerializerCache: {0}", e.Message);<br />
}<br />
I didn't post the whole block. I think the handler are not the problem, this also happened before i wrote this cache object, which attached no handler at all. I also had the problem, that the try-catch didn't worked, only the VS handler shows up. But I have to access to the exception object there, so I can't check the inner exceptions. Something weird seems to happen here...
Bye,
Florian
|
|
|
|
|
[7:35:12 PM] parthasarathy says: Hi all,
I am creating an windows application using vb.net. I am trying to deploy the project as exe. In this i am having few doubts.
(i) How to make my deployed application to check for latest version updated (as yahoo messanger)
(ii) How to Deployee an project with in an another project. For eg: First i deployed project 1, now i want to use/call the deplyoed Project 1 inside the Project 2 while deploying.
(iii) How to make my application to run on system start up?
Plz suggest me an solution
Thanks in advance
Regards
Anuradha
|
|
|
|
|
well, if you're using vb.net then you're in the wrong forum, anyway:
i. Make your application add a registry value with it's version and then make the program check for it's version (or check a web server for newer updates).
ii. Include the 2 projects and use System.Diagnostics.Process.Start to open the 2nd project's exe.
iii. Add a registry value the following subkey: "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", add whichever name you'd like and the value should be the application's path.
|
|
|
|
|
Thank you very much for your reply.
I am having an another problem in the Question 2.
As you told i inserted this code
"Include the 2 projects and use System.Diagnostics.Process.Start to open the 2nd project's exe." in my application.
Now i am facing different problem, I want to run the Project 2 at the system start up(everytime), how to write in the
"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", add whichever name you'd like and the value should be the application's path",
plz explain this with an example.
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
I want to create a fake file which would appear to be big but would take almost no space on the drive, since the question is quite vague i brought an example i saw on some forum:
http://img107.imageshack.us/img107/5246/bigfiles2xt3.png
I managed to find C++ examples but no C# ones.
And before you answer please notice i don't want the files to take much space on the drive (i already created a program that makes files but they take as much space on the drive as their size).
|
|
|
|
|
YOu can us p/invoke to call the win32api, or other c++ dlls. For the former see www.pinvoke.net[^]. The signatures there were auto generated and a few are problematical as a result, but the overwhelming majority word out of the box.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Isn't there a way to do this using C#?
|
|
|
|
|
yes, through p/invoke. The .net class library wraps all the normally used functionality of win32. IF you want to do weird stuff you still have to access the raw API.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
System.IO.FileStream fileStream = new System.IO.FileStream("test.file", System.IO.FileMode.Create);
fileStream.SetLength(9999999);
fileStream.Close();
File Not Found
|
|
|
|
|
Misread the question. A file reporting a size greater than it physically occupies will be caught on a disk error check like scan disk. So I can't see a particularly robust use for it (I am somewhat narrow minded sometimes)
File Not Found
|
|
|
|
|
There is the notion of sparse files and an fsdisk utility[^]
and a FileAttribute.SparseFile that sound good.
It is intended to skip sectors that would contain just zeroes, and is supposed to
work on some file systems only (NTFS yes, FAT no).
But I cant get it to work at all, it wont even keep the flag set (as opposed to hidden,
which gets accepted).
Luc Pattyn
|
|
|
|
|
hello
how can load one file to RichTextBox?
|
|
|
|
|
that would be simple for google.
By the way google is smart more than us, you can try asking it from time to time for basic questions like this
|
|
|
|
|
richtextbox has a property called Text which you can use to fill richtextbox with the strings.
richTextBox rtb = new richTextbox();
rtb.Text="hello";
|
|
|
|
|
|
Hi,
If its just the file you need to open and view the contents into a RichTextBox, you can use the OVERLOADED LoadFile() function which accepts a filename (filepath) as a string and a RichTextBoxStreamType as an another parameter
Eg.
this.richtextBox.LoadFile("c:\\temp.xxx", RichTextBoxStreamType.RichText).
The RichTextBoxStreamType.RichText should be used , if the cile to be opened in the RichtextBox is of RichTextType.
Refer MSDN for other flavors of RichTextBoxStreamType ENUM.
Thanking you in Advance
Regards
Pratik Shah
|
|
|
|