|
I have two C# .NET applications, AppA (located in folder A) and AppB (located in folder B). AppB is also using a lot of 3rd party dll:s and configuration files located in folder B. If I start AppB from folder B the application is working as expected.
The problem is when I start appB from appA using Process.Start(), and Process.StartInfo.FileName is pointing to appB. AppB is now starting up, but it seems like it is trying to load resources from folder A instead of folder B. How can I solve this? appB shall always load resources and dll:s from folder B.
modified 21-Jan-13 8:08am.
|
|
|
|
|
Have you tried setting the WorkingDirectory property of ProcessStartInfo?
|
|
|
|
|
Yes but is is still not working.
From AppB i print System.IO.Directory.GetCurrentWorkingDirectory() and that path is alright. I Also print all loaded dll:s and when AppB is started through Process:Start, some dlls are not loaded
|
|
|
|
|
OK I can't think of an obvious reason then. The only time I have seen the working directory set to that of the launching process is when ProcessStartInfo.UseShellExecute is true and Process.StartInfo.WorkingDirectory has not been set.
You say some dlls are not loaded. What is the mechanism for loading these and why doesn't AppB crash if it can't find them?
|
|
|
|
|
|
Thanks for all help. I got this working. The problem was timing problem in the 3rd party dll's. AppA is starting appB in a sandbox and adds overhead (=> timing problem). Because of this timeing problem a exception was throwed before all dll:s were loaded.
(difficult to give a precise explanation of a few short lines here)
|
|
|
|
|
Hi Fellow Developers,
I have created a Dot Net Windows application for my brother. It reads .jpg files and extracts exif information from them and then saves that information into a .csv file.
I have written it on a 64 bit machine. He either has a 64 bit, or a 32 bit machine. I'm not sure which. He runs Microsoft Vista. I run Windows 7.
I have built the dot net application using the target platform of x86, so I don't think that is why I am getting the following error.
Any and all advice on how to get the app to run on his system, is greatly appreciated.
All the Best to You!
Anne
ERROR IS:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {5F90E37C-44A0-47AF-A4CC-CCA80F0EBC83} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
at Microsoft.ImageMetadata.NativeAccess.loadWic()
at Microsoft.ImageMetadata.NativeAccess.get_WicAccess()
at Microsoft.ImageMetadata.NativeAccess.initImageTypes()
at Microsoft.ImageMetadata.MetadataPolicy.initImageTypes()
at Microsoft.ImageMetadata.ParseXml.load()
at Microsoft.ImageMetadata.MetadataPolicyManager.loadPolicy(String xmlFilename)
at OEE.DataAccess.ProcessTheData(String imgPath, String logFile) in C:\VS\OtherDotNetApps\OrionExifExtractor\OEE\OEE\DataAccess\DataAccess.cs:line 102
at OEE.DataAccess.ProcessDir(String sourceDir, Int32 recursionLvl, String logFile) in C:\VS\OtherDotNetApps\OrionExifExtractor\OEE\OEE\DataAccess\DataAccess.cs:line 82
at OEE.DataAccess.ProcessDir(String sourceDir, Int32 recursionLvl, String logFile) in C:\VS\OtherDotNetApps\OrionExifExtractor\OEE\OEE\DataAccess\DataAccess.cs:line 92
at OEE.DataAccess.ProcessDir(String sourceDir, Int32 recursionLvl, String logFile) in C:\VS\OtherDotNetApps\OrionExifExtractor\OEE\OEE\DataAccess\DataAccess.cs:line 92
at OEE.DataAccess.ProcessDir(String sourceDir, Int32 recursionLvl, String logFile) in C:\VS\OtherDotNetApps\OrionExifExtractor\OEE\OEE\DataAccess\DataAccess.cs:line 92
at OEE.Form1.btnLoadBCTphotos_Click(Object sender, EventArgs e) in C:\VS\OtherDotNetApps\OrionExifExtractor\OEE\OEE\Form1.cs:line 100
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.239 (RTMGDR.030319-2300)
CodeBase: file:
----------------------------------------
OEE
Assembly Version: 1.0.3.0
Win32 Version: 1.0.3.0
CodeBase: file:
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.235 built by: RTMGDR
CodeBase: file:
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.236 built by: RTMGDR
CodeBase: file:
----------------------------------------
Microsoft.ImageMetadata
Assembly Version: 2.2.912.3
Win32 Version: 2.2.0912.03
CodeBase: file:
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.233 built by: RTMGDR
CodeBase: file:
----------------------------------------
Interop.PptNative
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
|
|
|
|
|
Hi Fellow Developers,
After some searching, we found the solution.
I simply had my brother install the following:
http:
His system did not have
Microsoft.ImageMetadata
references in it.
All the Best to You!
Anne
|
|
|
|
|
I am developing a dynamic XPATH function for a MS XSLT transform. I am running the transform under a VB.NET (4.5) wrapper:
Public Function evaluate1(Context As XPathNodeIterator, Expression As String) As XPathNodeIterator
Context.MoveNext()
Dim nsXmlNamespaceManager As XmlNamespaceManager
nsXmlNamespaceManager = New XmlNamespaceManager(Context.Current.NameTable)
Return Context.Current.Select(Expression, nsXmlNamespaceManager)
End Function
The document to transform is XHTML with:
<!DOCTYPE html SYSTEM "file:C:/..path../parse1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
The XSLT document has:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:vb="urn:vb-script:xslt"
xmlns:http="http://www.w3.org/1999/xhtml"
I can successfully use XPATHs with the http namespace from the XSLT, but not in the function code's Select method.
Within the XSLT, the function is used as
<xsl:value-of select="name(vb:evaluate(., '/http:html[1]'))"/>
The function works with unqualified elements (no http: ), but if the namespace is used the "Namespace prefix 'http' is not defined." error is caught. I listed the contents of nsXmlNamespaceManager and see
xmlns=http://www.w3.org/2000/xmlns/
xml=http://www.w3.org/XML/1998/namespace
I know I should be able to add a namespace to the nsXmlNamespaceManager, but that would not be a general solution. It would seem logical to find the @xmlns:* attributes on the XSLT and add those to nsXmlNamespaceManager (assuming I could pass a reference to some XSLT object that would allow me to navigate to the xsl:stylesheet node (or pass a nodeset of those attributes to the function)).
Anyway, the search results on this subject are getting a little thin and I wanted to know if anyone had ventured down this path before and what they did?
|
|
|
|
|
I found a round about solution, but think it would be nicer to find the information in the object model from the function arguments. The round about solution was to read the XSL document (XmlReader) and extract the <xsl:stylesheet xmlns: attributes and from those create a XmlNamespaceManager (and XmlNameTable). The XmlNamespaceManager was passed to the XSL Extension class constructor which places the value in a private class variable that is used in the .Select argument list. This makes the wrapper program have to read the XSL document twice, once to find the stylesheet element and close/reopen to pass to XslCompiledTransform. It works and now the extension function evaluate can accept XPath with namespace prefixes.
|
|
|
|
|
I'm pulling my hair out over this one.
If I run all the tests in my solution 13 fail.
When my automated build runs on the build server all of the tests pass.
If I run one of the failed tests by right clicking inside the test (Visual Studio 2010) and clicking "Runs Tests" it fails.
If I run the same test using the little circle in the left gutter from ReSharper it passes.
This leads me to believe it has something to do with the Host type? But I am not sure.
The failure in the test has to do with a Method Not Found exception. The class under test, ClassA, inherits from ClassB (from a referenced assembly). Class B has a method on it that is being called in the code, and when the tests fail they do so because the method cannot be found.
Does anyone have any ideas about what might be causing this or how I can fix it?
EDIT: As it turns out MSTest is not copying the right version of my assembly to the Out folder, which would make sense why it can't find the method. The correct version is referenced in the Test project, not sure why it is hanging on to the old version, or where it's getting it from.
modified 18-Jan-13 11:44am.
|
|
|
|
|
Solution
I cheated a little. I didn't want to waste the time figuring out where my DLL was being cached. Using Windows Explorer I searched my solution folder and all subfolders for the assembly, changed the results to Details view and added File Version to the result columns.
I deleted all of the old versions of the files and re-ran the tests and now they pass.
Stupid %$!&!@(! MS Test.
|
|
|
|
|
Hi, in what book or an special website can I find useful, extensive and almost complete resources about the under the hood of .NET framework like CLR, DLR and so on?
|
|
|
|
|
MSDN, this book[^] are good places to start. The framework is so big, though, that you will never get complete information - you will just never need to use it all.
|
|
|
|
|
Thanks a lot. You mentioned that book to start but can you please name all the books you know about that maybe related to this subject I need?
|
|
|
|
|
Dear lord no. This is a huge area and it would take you 100s of books and 10s of 1000s of hours to master ALL of the insides of the framework, and by that time it will have grown again.
|
|
|
|
|
Not for advertisement, but take a look to the book "CLR via C#" by J. Richter. It's a nicely describe CLR and programming for CLR.
|
|
|
|
|
Yeah, I'm familiar with that name. I like to find more topics about that deepness in .NET.
|
|
|
|
|
Honestly the best way to learn how a runtime works is to learn how to debug it at the lowest levels. Read every single article here: Tess Ferrandez on MSDN[^]. Read if from start to end (well, actually end to start) and you should have really good in-depth knowledge (granted, reading and digesting that whole blog will probably take a few months). Real-world experience/stories sticks a lot better than raw theory (at least in my experience).
He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Chinese Proverb]
Jonathan C Dickinson (C# Software Engineer)
|
|
|
|
|
That blog is so useful. Thank you so much.
|
|
|
|
|
CLR via C# by J. Richter (though already mentioned above) would be my answer to a book.
There are some very good reads on msdn which go down in details of the framework.
Selective reading on http://www.wintellect.com/[^] will be useful for going in deep into the framework.
|
|
|
|
|
Perhaps you could download the source code of .Net framework and look into it:
http://referencesource.microsoft.com/netframework.aspx[^]
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore, Dream. Discover.
|
|
|
|
|
.NET is a layer on top of the WinAPI.
Learn that.
(WinAPI is a layer on top of HAL.DLL - you don't want to learn that)
|
|
|
|
|
can anyone help explain what might happen to a .NET application if file system crash? Simply put, should the apps pop up warning/error reminding that file system is carshed? How does your apps deal with file system crash?
Please help answer, many thanks.....
|
|
|
|
|
What do you mean by "file system crash", and how do you think the app could recognise it?
One of these days I'm going to think of a really clever signature.
|
|
|
|