Get application from dll in compact framework 2.0 - reflection

I am trying to write a method for a Compact Framework 2.0 dll which will return the name of the parent application from which the dll is called but I am struggling to see how to do this.
Using reflection I am able to get the dll I have written etc - any ideas how to get the application name?
Thanks
Morris

You can use
AppDomain.CurrentDomain.FriendlyName

And if you want the full path to the EXE:
Assembly.GetCallingAssembly().GetName().CodeBase

Related

Getting and storing the path of file in asp.net 5

In previous version of asp.net the HostingEnvironment had MapPath method to get and store the path of the file but in ASP.net 5 I can't use it.
var filepath = HostingEnvironment.MapPath(#"~/Data/product.json");
Are you using RC1?
In RC1 it depends if you are writing a console or web app. In console apps, you cannot use DI anymore but PlatformServices.Default.
PlatformServices.Default.Application gives you access to the base path of your application for example. The type of the static property is IRuntimeEnvironment. And having the base path of your app, you can easily build the path to files you need...
If you are building a web app, you should be able to inject IRuntimeEnvironment to your startup and use it from there.
You have to add a reference to the Microsoft.Extensions.PlatformAbstractions package to all that stuff.
See also my post here for more details
Despite IHostingEnvironment provides MapPath() method you may also need UnmapPath() too. Another useful method might be IsPathMapped().
You can find all of them here: Reading a file in MVC 6.
And all of them, thanks to PlatformServices availability, work in Consolse, MVC, and ClassLib apps.
HTH

Debug SimpleMembershipProvider source

I went through this article (http://msdn.microsoft.com/en-us/library/cc667410.aspx) which shows how one can debug asp.net source code.
Now, I'm having some serious trouble using the new SimpleMembershipProvider in WebMatrix.WebData namespace, and I want to debug it, but I'm not able to. When I try to step into the WebSecurity.CreateAccount method, it just steps over the method call.
I'm using Visual Studio 2012 Ultimate. What am I missing?
Is WebMatrix.WebData a third party dll? If so, you might need to decompile it, get the source and then add the source to your solution. Otherwise I don't think you'll be able to set into it.

what is Extensions in asp.net mvc2?

can u pls tell me what is the use of Extension( folder)/ how to use it in asp.net mvc2 framework...(extension is under the project name, like controllers, models, views...)
i mean the \Extension directory....
It's an arbitrary folder, just like /Joe/.
It probably contains extension methods.
The extension folder is nothing that comes with a new ASP.NET MVC 2 project. We can only guess what that folder might contain without seeing the actual source code.

how to find local image in asp.net project?

I have a solution contains a web project named "Web", and a dependeny class library project named "Service". I use the ASP.Net MVC2 to build up my solution. As you know, there's a Content folder storing images and css files under the web project. Now I need to get the stream reference of "Content\Images\anon.png" in one class of my "Service" project.
I tried
var result = new FileStream(#"Content\Images\anon.png", FileMode.Open);
and press F5 to debug, but it cannot find the file and throws an exception.
I am using VS2010, please tell me how can I access to this image. Thanks very much.
Can you try
Server.MapPath("~/Content/Images/anon.png")
You can use System.Web.VirtualPathUtility.ToAbsolute("~/Content/Images/anon.png"); or RequestContext.HttpContext.Request.MapPath as well
Visual studio makes it to a temp directory for your web app, not your solution folder/ If you publish your app on a IIS server, the Server.map will be correct.
Because it is searching for the file in Debug\Content\Images\ . Are you sure the images is really there? Make sure that your file is in that path.

ASP.Net resource files

I'm using selenium to run some functional tests on the UI for our current application.
I want to ensure that strings from the resource files in the Web project are being displayed at the correct time and place.
Simple (I thought) all I have to do is reference the assembly of the web application and assert that the text selenium is reading from the UI matches the test in the approriate resource file.
The problem is the ASP.Net does some precomilation processing on the resource files and compiles them into an assembly called App_GlobalResources, which isn't created by the normal build process so the functional tests fail because that can't find the App_GlobalResources assembly to look the string up from.
So, any suggestions? Do I need to abandon the App_GlobalResources approach and do something manual that I have control over?
Do you understand the problem or do I need to provide more info?
My interim solution is to use SVN:Externals to pull a copy of the resx files into the test project.
I can then access them via
ResourceManager resource = new System.Resources.ResourceManager("My.Web.Namespace.resources.ImageUrls", Assembly.GetExecutingAssembly());
Its ugly because I already have a reference to the webproject (which I can probably remove now...) and I don't like mixing source files between projects. It just feels like asking for trouble but until someone suggests something better this will have to do.
Have you considered moving your GlobalResources into a separate assembly and then referencing that from both your web project and your test project? This is quite easy to do in VS 2008, and achievable but a little more difficult in VS 2005.
I was able to solve a similar problem using that approach.

Resources