After converting a Web Site Project to a Web Application Project in Visual Studio, it seems that there is a problem with some meta data. The first noticeable is the fact that the project is mentioned twice in the Class View window.
If I add a new namespace and a new class in it, I'm not able to select it using intellisense. when I open the hierarchy of the Class view, I see my new namespace in one of them (that are indentical except the recent addings)
Is there a way to clean that up ?
You have to get rid off the App Folder. That's the origin of this problem.
http://vishaljoshi.blogspot.be/2009/07/appcode-folder-doesnt-work-with-web.html
Related
I am experiencing problem in VS 2022 in Blazor complex project. After moving Blazor components to different namespace/folder the components are not functional any more. My component does not 'recognize' other Blazor components anymore. For example custom component MudTable from MudBlazor namespace:
I would like to be able move Blazor components easily as simple classes.
Sometimes it helps to specify the same namespace in razor file to match namespace in partial code behind class, but sometimes I end up creating component (razor and cs files) with different name (copying the same code). This is very time consuming. I am not able to reproduce the described bug in Simple Projects. I have tried to reproduce the issue but it works fine (with minor VS bug) as described below. I will keep trying to reproduce the issue on Sample project.
Please find below scenarios working fine:
Simple scenario working fine
Steps to reproduce the issue:
Create Blazor Server App
Create folders
Components
Components\Sub1
Components\Sub2
Add new Razor component e.g. MyComponent1.razor to folder Components\Sub1
Verify that <MyComponent1\> works on some page. Eg. add lines to Index.razor:
#using BlazorApp1.Components.Sub1
<MyComponent1 />
Move MyComponent1.razor to folder Components\Sub2
Update Index.razor:
#using BlazorApp1.Components.Sub2
<MyComponent1 />
It works fine
More complex scenario with minor bug
Create Blazor Server App
Create folders
Components
Components\Sub1
Components\Sub2
Add new Razor component e.g. MyComponent1.razor to folder Components\Sub1
Add behind the class to 'MyComponent1.razor.cs' to folder Components\Sub1:
using Microsoft.AspNetCore.Components;
namespace BlazorApp1.Components.Sub1
{
public partial class MyComponent1:ComponentBase
{
}
}
Verify that <MyComponent1\> works on some page. Eg. add lines to Index.razor:
#using BlazorApp1.Components.Sub1
<MyComponent1 />
Rename folder Components\Sub1 to Components\Sub1Renamed.
Visual studio does not display any error and project can be compiled/started. Code behind is even displayed 'linked' to razor file:
This seems as a VS bug to me.
When project is started Component1 is invisible on Index page, because component 'BlazorApp1.Components.Sub1.Component1has no visual code defined, because it has only non-visual definition 'behind the code'. The file 'Component1.razor' with visual is not used at all because it is in unused namespaceBlazorApp1.Components.Sub1Renamed`
Update Index.razor:
#using BlazorApp1.Components.Sub1Renamed
<MyComponent1 />
When project is started, Component1 is visible on Index page (but I assume that no code behind is processed)
Do you have any hint, how to make it work for blazor components ?
I'm trying to change the container to DryIOC of a Xamarin.Forms + Prism app.
Visual studio is compiling and starting the app without errors, but when the app starts it doesn't fire App.OnInitialized method keeping the app on a blank screen.
What did I do?
Removed Prism.Unity, Unity and Microsoft related packages from the Android and Shared projects
Added DryIoc.dll (v2.10.7) and Prism.DryIoc.Forms (v6.3.0.1) packages to Android and Shared projects
Changed prism xmlns in App.xaml pointing to:
xmlns:prism="clr-namespace:Prism.DryIoc;assembly=Prism.DryIoc.Forms"
Changed the AndroidInitializer class in MainActivity.cs to:
public class AndroidInitializer : IPlatformInitializer
{
public void RegisterTypes(IContainer container)
{}
}
I created a blank app using the Prism DryIoC template and it works fine. Also, I compared the App.xaml, App.xaml.cs and MainActivity.cs files with those in my project and everything is OK.
What else can I do?
If you're converting over you'll need to do the following:
1) Remove the following three packages
- Prism.Unity.Forms
- Unity
- CommonServiceLocator
2) Update the xml namespace to clr-namespace:Prism.DryIoc;assembly=Prism.DryIoc.Forms in your App.xaml
3) Remove the Unity namespaces from your App.xaml.cs and replace them with Prism.DryIoc and DryIoc. Do the same in any IPlatformInitializer implementations, also changing IUnityContainer to IContainer
4) Update any service registrations since the signatures do not match between Unity and DryIoc.
5) Update any services or anything you specifically have that may directly use IUnityContainer to use IContainer.
6) Delete your obj and bin folders, clean and rebuild.
If you run into any trouble you can compare your project to either the Hamburger Menu or Tabbed Navigation samples.
UPDATE
Starting in Prism 7.2 the XML Namespace that is recommended for use is simply http://prismlibrary.com this will replace any clr-namespace declaration that you may have had previously and will work regardless of whether you are using an official Prism package or one of the Extended versions of Prism.
What worked for me was creating a new project using Prism DryIoC template and moving all my code it.
This is crazy, but I can't seem to get all my views/content/scripts published when I publish the site. This seems to happen, I believe, when the view or content is not directly referenced by my project, but used by another assembly in my project. So I might have:
ExternalAssembly.dll referenced (it gets published)
I'll need ExternalLogin.cshtml in my main project, under my views folder
ExternalLogin.cshtml doesn't get published
Right now I have a script that copies everything in the Views folder and dumps it to where I want it deployed, but VS should do this for me. What am I doing wrong?
When you click on one if these files what is the build action for it on the properties? Content....or? Set to content.
So your views files are in another project or folder outside your current project? Normally the files have to exist in the web site project, in it's views folder, not externally, and the build action should be set to Content and not to copy to the output folder. But there are some workarounds:
Duplicate them in to your site views folder and make sure they are marked content (as stated in another answer). One thing to note though is that you can add them as "Linked Files" in visual studio which actually allows them to exist in two places in the hierarchy without having to exist in two places on disk: http://support.microsoft.com/kb/306234
If you have control over the external library, you can compile them in as embedded resources or use Razor Generator or something similar and use a custom view engine to return them: How can I make ASP.NET MVC 3 use views (aspx, ascx) files from an external assembly in my website?
Manually put the copies in the .csproj build XML using the Copy task: http://msdn.microsoft.com/en-us/library/3e54c37h.aspx (Note that this will make it work in visual studio doing essentially what you are doing now, as it will then be part of the Visual Studio build if you add it to the AfterBuild target or something)
I was trying to add Web user control in Class Library in VS2010.
is there a way to do that?
at last I found one way,
just copy the files from other project (website/ web application) and pest them inside Class Library Project.
In a visual studio project I have three layers, Data Layer, Business Layer and Presentation Layer.
In the Data Layer I have a few XSLT's that transform some objects into an email, all works fine but I have discovered that the XSLTs do not get built/copied when building.
I have currently, created a folder in the deploy location and placed the XSLT's there but I am concerned about relying on a manual process to update these.
Has anyone encountered a similar issue and if so how did they get around it.
It smacks of changing the MSBuild script to copy the build artifacts to the required location, does anyone have examples of this?
Thaks
If you are using Visual Studio 2005/2008, the easiest way to do this is by including your XSLT files as project resources.
Open the Properties for your project.
Select the Resources tab. You will probably see a link that says "This project does not contain a default resources file. Click here to create one." Go ahead and click on that.
Click the Add Resource drop-down near the top and select Add Existing File.
Browse to your XSLT files and select them.
After you have done this, you can easily access the resources in the following manner:
// To get the contents of the resource as a string:
string xslt = global::MyNamespace.Properties.Resources.MyXsltFile;
// To get a Stream containing the resource:
Stream xsltStream = global::MyNamespace.Properties.Resources.ResourceManager.GetStream("MyXsltFile");
If you are using Visual Studio 2003, your best bet is to include those XSLT files as embedded resources for the DLL. In Visual Studio, select the file(s) in Solution Explorer, open the Properties pane, and change the Build Type to "Embedded Resource". You can then use the GetManifestResourceStream method to get a Stream containing the XSLT(s). The name to pass will be based on the default namespace of your assembly, the folder containing the file, and the name of the file.
For example, say your data layer assembly has a default namespace of My.DataLayer. Within your data layer project you have a folder named Templates which contains a file called Transform.xslt. The code to get your XSLT would look like this:
// There are numerous ways to get a reference to the Assembly ... this way works
// when called from a class that is in your data layer. Have a look also at the
// static methods available on the Assembly class.
System.Reflection.Assembly assembly = (GetType()).Assembly;
System.IO.Stream xsltStream = assembly.GetManifestResourceStream("My.DataLayer.Templates.Transform.xslt");
For more information check out this article on CodeProject.
Obvious question maybe, but still has to be asked, did you include the folder containing the XSLT's in the project itself? Is this a web or forms app?
In VS, it is easy to set the properties of the XSLT files in the project to copy on build, by default they do not.
I may have explained myself poorly.
THe Data layer is a class library that a the presentation layer references.
On building the DataLayer I can get the XSLTs to output to the Bin directory of the DataLayer. However when I build and publish the presentation layer, it correctly grabs the DLL but not the XSLTs