|
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.
|
|
|
|
|
You don't need to 'build as .NET 2.0' as you put it. If you're confident that it's compatible, you can use a .config file as follows:
<configuration>
<startup>
<supportedRuntime version="v2.0.50727" />
<supportedRuntime version="v1.1.4322" />
</startup>
</configuration> The file must be named the same as your program but with a .config extension, so if your program is MyApp.exe, name the config file MyApp.exe.config. If you already have an .exe.config file, add the <startup> section to the existing configuration file.
The documentation here[^] claims that the version that the software was built for will be used if it's installed, but my experiment indicates that this is incorrect: if a configuration file is present and specifies the runtime version to use, the first version specified which is installed is used. So if you want it to run on .NET 1.1 if available, or 2.0 if only that is available, specify v1.1.4322 first. The above file will use 2.0 if available falling back to 1.1 if 2.0 is not installed.
A Visual Studio 2005 .csproj file is an MSBuild input file, a 2003 .csproj file is not. MSBee[^] allows MSBuild to target .NET 1.1; however, you will need to (presumably) import your code into VS2005.
A word on debugging: if your application will load into .NET 1.1 you must use VS2003 to debug; if it will load into .NET 2.0 you must use VS2005. Neither version can debug the other's code. You won't get any warning, it will just stop debugging immediately after it starts.
Those are the rules for EXEs. For DLLs the EXE will control the version of the framework that's loaded, and you have to use that version - only one version of the framework can be loaded into a process. If the EXE is not itself a .NET application and you're producing a class for COM Interop, and the .NET Framework is not already loaded by the process, the latest version of .NET is loaded (not the version marked in the registry for the object). You can again control this with an .exe.config file (yes, even for native code programs that were not written with .NET in mind).
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
hi friends,
Does anyoone know how to use Nero SDk for burning DVD.
If so, pls let me know.
Thank you
Jack
|
|
|
|
|
Did you download the SDK because it'll surely have the documentation included.
AliAmjad(MCP)
|
|
|
|
|
Hi,
I have to create a SQL CE database file (*.sdf) on my PC. I intended to call several web services to get data and create a 'localDB.sdf' with a program running on my PC. I have created windows application project but I could not add reference to the System.Data.SqlServerCE assembly.
The System.Data.SqlServerCe didn't appear in the .net references tab. I had browsed and added the assembly manually but it didn't work because my framework is 2.0 and the assembly looks for CF 2.0.
How can I use the SqlCeEngine class in a Windows application? Or can I create a *.sdf file using a different class? Can I use CF assemblies on my PC?
thanks,
- ferudun
|
|
|
|
|
Please don't cross post. You asked this same question here[^] about 10 minutes earlier than you posted this one.
The people here answer questions on a volunteer basis and may not respond in a timeframe you desire or find acceptable.
|
|
|
|