|
Thanks, I'll look at that when I get to work.
I initially tested my app with a simple web.config file. This file has your typical configuration section with a appSettings, connectionStrings, and a web.config section. That was working pretty well, so I decided to try it with one of our production web.config files (significantly larger and more complex). This file has the same stuff as the other one, as well as a configOptions section. A significant difference between the two files is that the production one has comments.
I'm trying to use Alvaro Mendez's read/write XML article [^] as a stepping off point because I haven't found ANY class that can handle the entire web.config file (none of them can read the connectionStrings section). His article doesn't do the namespace thing (and doesn't read the connectionStrings section), and seems to work fine on my small file, but chokes/pukes on the "real" config file.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
What I'm wondering is if this is a "standard" web.config why do you need namespaces?
|
|
|
|
|
I tried namespaces because of the stuff I found on the web regarding SelectSingleNode returning null. That didn't work any better than not using them. :/
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hmm, I did have a problem with SelectSingleNode before now that you mention it, the work-around I had was to use the indexer of the collection and check whether it was null .
Perhaps there's a bug in the 2005 version, the code I supplied worked on VS2008 with 3.5 framework, I can retarget it to compile against the 2.0 framework if it's any help.
|
|
|
|
|
I think I found my answer (detailed in another reply).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I figured out why it's not working. The web.config file in question has the following:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
It therefore has a problem finding any section contained within the configuration section. When I delete the xmlns attribute, my code works. Any idea how to ignore this programatically? .Net doesn't seem to have a problem parsing this web.config...
-- modified at 9:13 Tuesday 30th October, 2007
I have found references on google that claim the xmlns attribute isn't needed. I'm going to go ahead and delete the attribute and see if the associated web site still works.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Ok the problem seems to be that .NET 2.0 supports XPath 1.0 and XPath 1.0 does not support default namespaces. To get around this you can do the following (for some reason ):
Sample Xml File
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<connectionStrings>
<add name="SQL" connectionString="SQL" />
</connectionStrings>
</configuration>
Sample code:
using System;
using System.Xml;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
XmlDocument dom = new XmlDocument();
dom.Load("Web.config");
XmlNamespaceManager manager = new XmlNamespaceManager(dom.NameTable);
manager.AddNamespace("default", "http://schemas.microsoft.com/.NetConfiguration/v2.0");
XmlNode node = dom.DocumentElement.SelectSingleNode("default:connectionStrings", manager);
if (node == null)
Console.WriteLine("(null)");
else
Console.WriteLine(node.OuterXml);
}
}
}
Notice where I added the default namespace with a assigned name default , the documentation says that the default namespace should be string.Empty but this does not work, if you give it a namespace then it does.
Hopefully it'll support XPath 2.0 at some point.
|
|
|
|
|
Is there a way to create an application that can run under MACs?
|
|
|
|
|
Yeah - create the app on a PC, put your mac on the pc, and then run the app on the pc.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Take a look at the first google result for ".net mac osx"
|
|
|
|
|
Theoretically, MONO would work, but you would have to be careful with this because the MONO support for .NET is patchy in places.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have a project to do called Multithreading and in this lab I have to creat A console application and start two threads simultaneously.
1. I created a console appleation and called it System.ThreadingDemo.
2. I need to creat a new static method called Counting. I'm not so sure how to go about it? I need feedback here.
3. In the new class, I need to add a using statment or the import statement for VB
to the System.Threading namespace? I need a feedback here!
4. In the new method, I need to creat a for loop that counts from 1 to 10? How would you do this?
5. within the New for loop, write out the current count and the ManagedThreadID for the current thread. I need a example here.
6. after writing out to the console, I need to sleep the current thread for 10 milliseconds.
I could use some feed back here.
7. I need to go back to the main method, and create a new ThreadStart delegate that points to the Counting method. Like what? what do they mean point to?
8. Now at this point I need Two threads, each pointing to the counting method.
How woud you code two more threads here?
This is a CODE example of a school project.... it needs work
after all said and done I have to Start both threads and join both threads to ensure that the application doesn't comloete until the threads are done. My code should look something like this:
Imports System.Threading
Class Program
Public Overloads Shared Sub Main()
Dim start As ThreadStart = New ThreadStart(AddressOf Counting)
Dim first As Thread = New Thread(starter)
Dim second As Thread = New Thread(starter)
first.start()
second.start()
first.join()
second.join()
console.Read()
End Sub
Shared Sub Counting()
Dim i As Integer
For i = 1 to 10 step i = 1
Console.WriteLine("Count: {0} - Thread: {1}" , -
i,Thread.CurrentThread.ManagedThreadID)
Thread.Sleep(10)
Next
End Sub
End Class
'You can copy this and use work with it, just let me know what you think.
-- modified at 8:37 Tuesday 30th October, 2007
tim637
|
|
|
|
|
Thanks for your code.
Was there a question somewhere?
If so, try make it more specific than "I need help!"
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: Was there a question somewhere?
If there is, I sure missed it
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I can see how the question could have been missed, but 1-8 is what I need help with, the code I put at the bottom was a example. Threading is such a big thing on a high level, its good to know.
tim637
|
|
|
|
|
please find the good resource related to threading..........
http://www.codeproject.com/csharp/threadinginnet.asp
http://aspnet35.blogspot.com/search/label/Threading
|
|
|
|
|
Thanks for the help.
tim637
|
|
|
|
|
Hello, I’m triying to load and execute managed code using methos as shown belong
<br />
SAFEARRAY * psArr;
SAFEARRAY * Param;<br />
CComPtr <ICorRuntimeHost> spRuntimeHost;<br />
CComPtr <_AppDomain> spAppDomain;<br />
CComPtr <IUnknown> spUnk;<br />
CComPtr <_MethodInfo> MI;<br />
CorBindToRuntimeEx( NULL, L"wks", STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN,<br />
CLSID_CorRuntimeHost ,<br />
IID_ICorRuntimeHost ,<br />
(void**)&spRuntimeHost);<br />
spRuntimeHost->Start();<br />
spRuntimeHost->CurrentDomain (&spUnk);<br />
spUnk->QueryInterface(&spAppDomain.p);<br />
try<br />
{<br />
MI = spAppDomain->Load_3(psArr)->GetEntryPoint();<br />
Param = MI->GetParameters();<br />
MI->Invoke_3 (NULL, Param);<br />
}<br />
catch (_com_error ex)<br />
{<br />
std::wcout<< ex.ErrorMessage();<br />
}<br />
SafeArrayDestroy(psArr);<br />
So if I invoke GUI application all good, but if I invoke Console application Invoke_3() function rise an exceptional situation…
Who has any ideas how to run Console Application?
|
|
|
|
|
What is the exception that is being thrown?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
|
Where are you initializing psArr?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
CorError.h (in the SDK\v2.0\Include folder under your Visual Studio installation, for VS 2005) documents this as follows:
#define COR_E_SAFEARRAYTYPEMISMATCH EMAKEHR(0x1533L) I suspect that it's this bit from the documentation that's causing trouble:
"parameters
An argument list for the invoked method or constructor. This is an array of objects with the same number, order, and type as the parameters of the method or constructor to be invoked. If there are no parameters, parameters should be a null reference." (my emphasis)
If your console application's Main method doesn't take any parameters (which is permitted) I think GetParameters may give you an empty array, not a NULL pointer. But try it and see.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
A NULL Parameters works ONLY if we have windows GUI Application, but if we have a Console application - it rise an Exception
|
|
|
|
|
If we running Windows GUI Application, then parameters could be NULL, but if we try to run console application, parameters must not be NULL, or we will take exceptional situation
|
|
|
|
|
Is it possible to build a .NET 1.1 project as a .NET 2.0 project without converting the project files? I need to continue developing the applications in VS 2003 but build as .NET 1.1 and .NET 2.0. I am hoping this can be done via a build script but I have tried using msbuild with my .csproj files with no luck.
Any ideas gratefully received.
|
|
|
|