|
I'm trying to create a System.Drawing.Image from a user supplied URL. My code is as follows.. I keep getting a "(407) Proxy Authentication Required" Error.
WebClient imgClient = new WebClient();
String imgURL ="http://www.blah.com/image.jpg";
byte[] imageByteArray = imgClient.DownloadData(imgURL);
MemoryStream ms = new MemoryStream(imageByteArray);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
|
|
|
|
|
|
I would like to check to see if an XML document is well formed without relying on exception based logic. (ie no try catch block), ideas? XmlTextReader does not seem to work as it will only throw an exception.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
|
The Validating Reader in .NET relies on the XmlTextReader which requires the input to be well formed or it throws an exception. I would like to determine that a given input is not well formed without an exception.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
One way to do this would be to read the data in and generate a parse tree out of it. If you get any unbalanced elements, then it's not valid XML. This is a lot slower than just catching an exception, but it is doable.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
If there is a method that throws an exception then it is possible for a method to exist without an exception that does not suffer the performance penalty of exceptions.
Pete O`Hanlon wrote: This is a lot slower than just catching an exception
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: If there is a method that throws an exception then it is possible for a method to exist without an exception that does not suffer the performance penalty of exceptions.
I don't quite understand this. Sure there is an overhead when throwing an exception but surely badly formed Xml is an exceptional circumstance that should therefore be dealt with by raising an exception.
If you expect the Xml to be malformed (and you're therefore remembering not to control program flow with exceptions) then frankly you're not dealing with Xml - you're dealing with a string of data that sometimes looks like Xml.
I suspect this is the case, and you're being provided with a string of data that is sometimes malformed. This swings you back in a circle - because you can't change that process that generates the Xml (presumably??) and so you're back to an exception.
|
|
|
|
|
I am accepting user input which must be well-formed XML. From your post you do not make a distinction between application thrown exceptions and application driven exception flows. In both cases the user is presented with a graphical exception flow requesting better data; however, in one of the cases the underlying code is not dependent on a try catch but a series of programmatic statements.
This all leads down to the same path
if(!IsWellFormed(someXml))
is better than
try{
//Or other derivatives
XmlDocument document = new XmlDocument();
document.LoadXml(someXml);
}
catch{
...
}
J4amieC wrote: I suspect this is the case, and you're being provided with a string of data that is sometimes malformed. This swings you back in a circle - because you can't change that process that generates the Xml (presumably??) and so you're back to an exception.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Ok cool. So the option you have as far as I see it is to write your own parser that does a few things, ie/
1) count elements to ensure balance
2) check common syntax errors like a missing quote on attributes
But something would stop me from doing this and just go with the method you've mentioned you dont want to use. Mainly as it seems like re-inventing the proverbial wheel.
|
|
|
|
|
No, I am just going to use a try/catch block. I just figured I would ask on CP to see if anyone knew offhand. I don't like using it but I am definitely not going to spend the time writing my own parser.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: If there is a method that throws an exception then it is possible for a method to exist without an exception that does not suffer the performance penalty of exceptions
I agree - except for the fact that the inbuilt .NET parsing was designed to throw an exception if it encountered an error. The point that I was making is that, coding wise, it's a lot more expedient for you to catch the exception because this means that the input was malformed - i.e. is exceptional.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi! All
I m playing to Enterprise Library May3.1; I encouter an error while validating properties "Could not load file or assembly". or "invalid assembly or codebase";
And i encounter an error at design time "
at the code ValidationResult r - Validation.Validate(customer);
the error is: Could not implicity convert Microsoft.Practices.Enterpriselirary.ValidationResult into Microsoft.Practices.Enterpriselirary.ValidationReuslt;
so how i tackle to these problem any suggestion will be anticipated.
|
|
|
|
|
I am using clickonce to deploy an application.
This works fine on my test machine where I develope .net applications.
Now I would liket oinstal it on other machines which do not have .net framework installed.
How do I add the .net framework to clickonce during instal please?
|
|
|
|
|
You don't, .NET 2.0 implements ClickOnce and therefore must be deployed before you can deploy your application.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
I have a solution in VC#2008, now I want to open it in VC#2005, is it possible, any solution?
because vc#2008 can not installed on my notebook computer, that's why I use vc#2005 instead.
thanks.
|
|
|
|
|
xiachunmin wrote: I have a solution in VC#2008, now I want to open it in VC#2005, is it possible, any solution?
because vc#2008 can not installed on my notebook computer, that's why I use vc#2005 instead.
If you use any of the new features in VS2008 then you cannot go backwards. If you don't use any of the new features then VS2008 can save it as a .NET 2.0 project which will work.
|
|
|
|
|
thanks, but how to save it as .net2.0 project? save what? *.sln? how?
|
|
|
|
|
I don't have VS2008 in front of me right now. But as I recall you can right click the project or solution and select properties. From there you should be able to find a drop down (combo box) with the target framework. Target it at .NET 2.0. VS will request to reload the solution/project (because it needs to unload the project/solution, make the change to the file then reload it)
|
|
|
|
|
1) create a new VC#2005 solution where your VC#2008 poject is, but with a different name
4) solve compilation errors
5) you're good to go
What I do is, I have both solution files on the same folder, using different names, for instance MyProject.sln and MyProject2008.sln, and I can use either, with the same source files and all and all. I don't know what would happen to the project settings, though, like post-build events and other compilation settings.
All in all, you'll find less problems than you think.
Oh, and when you use VC#2008, make sure that "Target Framework" is .Net 2.0, and not 3.5 or 3.0. VC#2005 doesn't have the same support for the lattest versions. And there may be some syntactic sugar added in 2008, but you probably stumbled upon it and will recognize it when the compile errors come up.
"Computer Science is no more about computers than astronomy is about telescopes." - Edsger Dijkstra
|
|
|
|
|
Hi,
I have a Managed Application, working fine on mine system.
I want to install it on the clients machine .Can I include any libraries or Dlls related to .Net Framework so that my application runs on client side?
So that the client need not install .Net Framework.
If it can be done, how? Any suggestions would be helpful.
Thanks
Today is a gift, that's why it is called the present.
|
|
|
|
|
There are some very expensive applications that will allow you to merge the .NET runtime into your executable. What is the problem with installing the .NET runtime on the client though? Do you have a reason why this can't be done?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
How to implement Drag&Drop capability of a WinForms application, when we want user to be able to drag and drop files and directories outside the main form through FileDrop?
Dragging files from e.g. Windows Explorer to WinForms app is not a problem. But the reverse way is a big problem for me.
|
|
|
|
|
You need to do something like this:
string[] aFiles = ** filenames of that you want to drag out **;
DoDragDrop(new DataObject(DataFormats.FileDrop, aFiles), DragDropEffects.Copy | DragDropEffects.Move);
If the files you want to drag out aren't actually real files, the easiest solution is probably to create temporary files, and provide those filenames.
|
|
|
|
|
Hello...
I have a problem. I'm using an ActiveX Control and the ActiveX Control need a reference to MainMenu and MenuItem.
In VS2005 you can only add MenuStrip and ToolStripMenuItem.
Are there any possibilities to convert the MenuStrip to MainMenu and ToolStripMenuItem to MenuItem ?
Thanks...
|
|
|
|