Why does my MVC application report the GetExecutingAssembly Name as App_web_xxxxx.dll? - vb.net

I am updating our CruiseControl.NET continuous integration environment from using the old Visual Studio 2008 Web Deployment projects to Visual Studio 2010.
I do not want to use the Beta 2010 Web Deployment projects as I think I can make use of the updated Publishing/Packaging in 2010.
Currently I have managed to configure the CruiseControl script to call MSBuild twice. First to Build the solution in the Release configuration and then to Package the MVC project.
I then copy out the correct files from the Package from a hideous file path (which makes me suspect I am not doing this right but heh) and the Transformed web.configs to the Test server.
This is finally working but unlike when I used the 2008 Deployment Projects this code returns the ExecutingAssembly as App_web_xxxxx.dll and not Company.Product.Web.dll which is what I'm after.
Dim CurrentAssembly As Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly
Dim version As String = CurrentAssembly.GetName.Version.ToString
I know GetName returns the a longer string than just the name but I'm debugging it to see what it contains. I understand that is is the compiled/cached dll but why isn't it the one in the MVC bin.
Cheers

I figured this out - basically when I was calling Assembly.GetExecutingAssembly inside the footer.ascx. This meant that the code was in a dynamically compiled dll for the footer.
What I wanted was the DLL for the MVC website. So I used an extension property on the controller that set ViewStates with the Assembly information.
In my case I will want to use this code again so the extension property is in a different Assemmly that I can include in various MVC projects. This meant I had to change the code to use Assembly.GetCallingAssembly but it now works exactly how I wanted.

Related

What can I do with the LINQPad.Runtime?

Just learning about LINQPad and I am trying to do understand what I can do with the LINQPad.Runtime NuGet package. Where can I find the docs for this? Also, is this package the right one for NET6?
If you reference this package from a Visual Studio project, you can call Util.ToHtmlString to format objects as HTML via the Dump pipeline. You can also call Util.Run to execute LINQPad scripts - this makes it easier to pass parameters to the script and receive return values than shelling out to lprun.
LINQPad.Runtime works all versions of .NET >= .NET Core 3.1.

app.config “Could not find schema information” after converting to Visual Studio 2010 / .Net 4.0

i am working on vb .net project. it was working fine till yesterday. i m trying to build it today but its giving me following build errors.
1 Could not find schema information for the element 'supportedRuntime'.
2 Could not find schema information for the attribute 'version'.
3 Could not find schema information for the attribute 'sku'.
i tried few things but it is not working fine. I tried selecting the DotNetConfig.xsd from the properties of app.config. it didnt work. I chose some other schema then it is selecting both the schemas. and throwing some other bunch of errors too. I tried killing the process from the task manager. i tried replacing the app.config.
What should i do?
P.S: i am using visual studio 2010 version.
and .net framework 4.0
Close the solution, then re-load it and Rebuild

Clr Assembly must have main file specified error

This is the first dll I have made. It's purpose is to grab territory names from a database and return as an mdx set. The dll compiled perfectly fine, but when I go to deploy the dll as an assembly in bids to my cube, I get the following error:
Clr Assembly must have main file specified error
The dll is supposed to be like a ssas stored procedure so I can set permission in a role for ssas.
Thanks!
Ethan
I finally figured out a solution! I believe that because of the msmgdsv.dll being of framework 2.0 I didn't like the file, so I changed the target framework under the project properties to Framework 2.0 from Framework 4.0. I then went to deploy everything from BIDS and instead of an error, It deployed!

SVCUtil "update service reference" equivalent command parameters

I want to update service references in a Visual Studio 2010 solution by using SVCUtil because this solution has several projects and it's not good to get references refreshed one by one.
I'd like to know your point, because I've to be sure I'm going to execute exactly same command than one done by Visual Studio 2010, or even if Visual Studio 2010 doesn't use SVCUtil, an equivalent command to IDE's behavior.
Thank you very much.
The easiest way to refresh a lot of service references is to put all those in a dedicated project. Reference this project from all the projects that need to use them.
If a service reference needs to be updated, you will do it in one place only.
Some googling here and here shows the settings on VS 2008, although this will depend of course on your options in the Advanced options in the Add Service Reference wizard.
From : http://geekswithblogs.net, Dave Barrett, 30 June 2008:
Contrary to Visual Studio 2005, the Add service reference command in Visual Studio 2008 does not use svcutil.exe, but rather it's own built-in functionality.
Using a comparison reference between the two and my own analysis of the results, I came up with the following command to mimic what the command does in VS 2008 (keep in mind a few of these options, such as the /ct and the /l switches, were specific to my situation):
svcutil *.wsdl *.xsd /l:C# /out:Reference.cs /noconfig /s
/ct:System.Collections.Generic.List`1 /ser:Auto /tcv:Version30
/n:*,<NameOfYourNamespaceHere> /edb
I ran this in the folder where the schema files (WSDL, XSD) were located from a VS2008 command line.
Edit : Agreed - Never be afraid to drop and recreate service references from scratch. When working with version control like TFS, "update" service references there is often quite a mess as it figures which wsdl, xsd and disco files etc have been changed, added or deleted etc (and get filenames like SomeXSD92.xsd). Generally it is quicker to just drop and recreate them.
Johan's post is makes a good point (and can be used as part of a standard design pattern called Service Agent which handles the implementation of the client proxy).
I'm not quite sure what you mean when you say two tiers would need to reference the same assembly? If you are sharing type of the entities called in the service you would need to reference the entity assembly in most tiers anyway. For your Service Agent assembly project (which has all the service references) you can either re-expose the same Service Contract used by the WCF server or wrap it in a new interface.

How do I change Process Template on an existing Team Project in TFS 2010?

How do I change process template to MSF for Agile on an already existing team project in TFS 2010?
We have upgraded our TFS 2008 to 2010, and now I would also like to change the process template to MSF for Agile (currently CMMI).
We haven't used the workitem functionality much so if some information gets lost in the conversion doesn't matter.
Once you've created a Team Project, you unfortunately can't just upload a new process template. As Robaticus says, you'll have to download the XML for the template and modify it, then re-upload it. The power tool lets you create NEW templates for NEW team projects, but it won't modify an existing one.
Instead, you can use the witadmin.exe tool (on any computer with Team Explorer installed, under \Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE, or just from a Visual Studio Command Prompt) to export the current workitem definitions and re-import them once you've made your changes.
Luckily, if you're not using workitem tracking much, then this might not be too difficult. You might be able to just delete all the existing workitem types and then re-upload the new types.
If this is too much trouble, consider how much you want to retain your source control history. It might be worth creating a new Team Project with the Agile template and then just moving all your source code into it.
You can't change the process template, however you can change the work item types. So for bugs, tasks you can swap to the Agile definitions.
You can do this in 2010 with witadmin, in 2008 it's importwit, by first downloading the template to disk (you'll need the TFS power tools for this). Then point the console app at bug.xml, task.xml etc..
Usage: witadmin importwitd /collection:collectionurl [/p:project] /f:filename [/e:encoding] [/v]
/collection Specifies the Team Foundation project collection. Use a fully specified URL such as
http://servername:8080/tfs/Collection0.
/p Specifies the team project in which the new work item type is imported. This is required, except when
the validation-only option is used.
/f Specifies the work item type XML definition file to import.
/e Specifies the name of the .NET Framework 2.0 encoding used to import the XML file. For example,
/e:utf-7 will use Unicode (UTF-7) encoding. Encoding is automatically detected whenever possible. If
the encoding cannot be detected, UTF-8 is used.
/v Validates the XML definitions for the work item type, link type, or global workflow without importing
them.
You can export the agile process template to disk, then import the work items into your existing project. You may need the TFS Power Tools to do this.
I may be too late for this question, but the TFS Integration Platform tools could really help here.
See this question on server fault that details on how to move from Scrum For Team System V2 to Microsoft Visual Studio Scrum 1.0.
You would need to setup your own mappings to move from your templates to the target template, but the process is the same.
Please note witadmin.exe could help in some scenarios but TFS Integration Platform is your ultimate choice to achieve this task. There is a user voice item still pending. Please check this SO thread.
I think the best way to accomplish this is to create a new Team Project with "the new" process template and use the TFS Integration tool to migrate your existing WorkItems and choose create a new branch from Source Control, so you'll have new work Items (with the new workflow) and the source control history (as well). You'd even do this across versions of TFS!! (On the case interested on migrate TFS 2005/2008/2010)
Another way might be to use the WorkItem Templates, but I think this is more a kind-of visual style (I've not much experience) applied to the Work Item. To do so, just right click on your project, import the WITDefinition and apply the template by selecting Apply template on desired WorkITems.