|
To see what is going on, you could just load the document from the url into a string first so that you can see if it is an issue with the request or response first. Once you have the string you just need to parse it into your XmlDocument. It adds a line of code, but it makes debugging and viewing your variables much easier.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
That is what my "Ugly Hack" that I posted does. Using 7 lines of code, it reads the XML into a string and looks at that string before deciding if the XML is to be loaded. Just seems like a terrible waste of time/resources. I don't understand why it doesn't simple kick out an XmlException as the documentation says it should. The server 500 error gets me every time.
Thanks for responding.
|
|
|
|
|
My hunch is that the error isn't coming from your own code. Are you running this code in a web application? If so, then maybe, but if your application isn't a web application then the likely source of the 500 error is the site you are trying to hit. If the source site is working properly when you enter your full url into a browser, then you may have an issue with how your url is constructed as well.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Yes, my site is an asp.net web application. The error occurs anytime I try to load something using XDocument.load() that isn't in proper XML format. Wrapping it in a try block like I show above does no good. You can't validate the XML against an XML schema util you have it loaded...kind of a catch 22 in my case. I don't like the idea that XDocument(url) can stop my web-application from functioning (internal 500 error). The error does not come from my web-app code, it comes from the server running my web-application anytime I try to load fouled-up XML.
My hack has it working for now but I am certain that I am overlooking something simple. I guess if there were a simple fix, someone would have posted it by now.
Thanks again,
modified 21-Dec-11 18:20pm.
|
|
|
|
|
Enochs wrote: catch (XmlException ex)
What makes you think that that is the only possible exception that can be thrown? If another exception is thrown then it is going to result in some error response to the client (which is what you are seeing.)
Also maybe your url in the catch is failing.
Also shouldn't you log something if it fails?
modified 23-Dec-11 15:55pm.
|
|
|
|
|
Hello Everyone,
Actually I am facing one problem, please help me...
How to create schema in ms-access database using C# code?
Thanks in advance!!
|
|
|
|
|
Your question isn't very clear to me, however this[^] could be the answer.
|
|
|
|
|
Actually I want to create ms-access database with some schema name with the help of c# code.
|
|
|
|
|
Sorry, can't help you there; I have been using both Access and SQLServer, but always migrating away from Access, never creating one.
|
|
|
|
|
Using Interop you should be able to do this. That assumes you know how to create databases, tables etc using Access objects. You might be able to do it running SQL queries in Access - again assuming you know the required SQL. You can pick up some of it in the Access designer for queries - just create a make table one then switch to SQL view.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
Here is my suggestion. IF you have a copy of access, use it create the tables and views that you need. After doing that, you can write your C# application to use the Access database. I think you will find it a lot easier to create the database within MS Access that try to create it using C#.
|
|
|
|
|
Hi all,
I have created setup for my program . This setup creates shortcut icon on my desktop. But this icon have wrong target set. Target shown is 'MyInstaller' ( where 'MyInstaller' is deployment project name ). When I check other shortcuts available on my desktop, I found Target is set to '"C:\Program Files\Beyond Compare 3\BCompare.exe"' (for example). Why all the shortcuts created by me do not have such target? I wanted to use the target to process my documents.
Do I miss some settings here?
Thanks in advance !!
Amit
|
|
|
|
|
Show the code you use to create the shortcut, there is probably something wrong in it.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi Richard,
Thanks for the reply.
I haven't write any code for this. I followed below steps 1) add 'Setup Project' to the solution. 2) right click on Project, select 'View' => 'file system' 3) add 'primary output' to the Application Folder 4) create shortcut by right clicking on the primary output file 5) move this shortcut to the 'User's Desktop' folder Any idea how this can be handled?
Amit
|
|
|
|
|
Sorry, I have not used this process so cannot offer any suggestions, other than to suggest you check carefully that each step is referring to the correct object.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
ok...do you have any example of 'using Installer class' for deploying windows projects? or any other way for installation process?
Amit
|
|
|
|
|
iamdking wrote: do you have any example
I'm afraid not, that's why I said "cannot offer any suggestions". However, you could try a Google search for 'using Installer class' and see what that comes up with.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi Richard,
Thanks for reply. I got help from this url [^]. My app is working now..
Amit
|
|
|
|
|
Hi everyboody
I tried DirectX.Capture modified can be archived into a wmv, but I do not know how to share?
|
|
|
|
|
I have these 5 method objects. These 5 method objects have exactly same function calls. Example as below:
int method = 3;
int result = 0;
Method1 m1 = new Method1();
Method2 m2 = new Method2();
Method3 m3 = new Method3();
Method4 m4 = new Method4();
Method5 m5 = new Method5();
switch (method)
{
case 1: m1.SolveThis(ref int result); break;
case 2: m2.SolveThis(ref int result); break;
case 3: m3.SolveThis(ref int result); break;
case 4: m4.SolveThis(ref int result); break;
case 5: m5.SolveThis(ref int result); break;
}
(inside each m* contains different methods, for the sake of arugment).
Is it possible to do this as below?
Object mm;
int method = 3;
int result = 0;
switch (method)
{
case 1: mm = new Method1; break;
case 2: mm = new Method2; break;
case 3: mm = new Method3; break;
case 4: mm = new Method4; break;
case 5: mm = new Method5; break;
}
mm.SolveThis(ref int result); // this line doesn't see "SolveThis" funtion in .NET.
Anyone have any thoughts?
|
|
|
|
|
Blubbo wrote: Anyone have any thoughts?
Yes. A head full.
1. What you probably want is called an interface . Have all these MethodX classes implement a common interface which is a promise to implement whatever you like, such as a void SolveThis(ref int) method.
2. Please use PRE tags when posting code (or tabular data). It improved readability.
3. Your choice of names is horrible. A method is a method, a class is a class; don't define a class called MethodX. SolveThis is another poor choice, "this" has a special meaning in object-oriented languages such as C#.
4. Why is it your SolveThis method using a ref parameter, and apparently not using any return value?
5. If you're new to C# (or to programming in whatever language) I strongly recommend you choose, buy and study a book (a real book, one you own) and acquire good practices from day one; it is the easiest and fastest way to make real progress.
|
|
|
|
|
1) I haven't used interface in my code before... the next responder by RobCroll has suggested a good solution for my question.
2) Yes, I am aware of PRE tags but apparently forgot to include that in my initial posting. My bad!
3) I was having hard time on what to say to give the reader the example without revealing important codes in my source (its work related).
4) I use int return value to provide the error code in case the function call failed to process. that's why I use ref parameter.
5) I am not new to C#. I have few books here and also online resources to help me out... I am still working on improving the efficiency of my codes.
|
|
|
|
|
Blubbo wrote: I have few books here
Every book on C# is bound to discuss interfaces, so my best advice is to read one of those books you have from cover to cover and you will learn some of the basics you seem to be lacking right now. Browsing some on-line material is no substitute, it is a handy addition.
|
|
|
|
|
Create an interface get the other classes to implement that interface
interface ISolution
{
int SolveThis(int question);
}
public class SolutionClass1 : ISolution
{
...
public int SolveThis(int question)
{
return result;
}
}
ISolution solution;
int method = 3;
int result;
switch (method)
{
case 1: solution = new SolutionClass1; break;
case 2: solution = new SolutionClass2; break;
case 3: solution = new SolutionClass3; break;
case 4: solution = new SolutionClass4; break;
case 5: solution = new SolutionClass5; break;
}
result = solution.SolveThis(result);
"You get that on the big jobs."
|
|
|
|
|
hmm... this might be the solution to my question. I'll give this a shot. Thanks!
|
|
|
|