Can not change original file name,Compiler Error Message: CS0433: - c#

It's a little bit complicated.I got a .net class library project form someone else and added it in my solution referenced by a asp.net mvc project. For some reason I changed the project name form "abc" to "xyz" and also Assembly name, Default namespace name in project properties page. I could build the solution and get the xyz.dll in the bin folder.
The problem is I can't run the web application because of the error "Compiler Error Message: CS0433:". I looked into the folder "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\" and found out the abc.dll still there and I checked the file detail information on properties page. The file description and product name are the same xyz, but the original filename is still abc.dll. I really don't know what's going on here.
I wish some could help me out,Thanks in advance.

You have to delete abc.dll from the root directory and then recheck it. Because IIS configure with this file and after changing it will not rebuild with this files as well.

Did you rename it in a file explorer or using Visual studio? Check the .csproj file and the .sln file and make sure all references in there reflect the new names. Also, check your dependencies and references to make sure they point at the new dll, and not the old one

You probably have figure it out but for other peoples who might search for the solution.
Right click on your solution or project file -> Click on properties -> And then there is first tab with name application Click on that. You will find two text box one for Assembly Name (Change this to xyz).
see attached image.properties dialogue box

Related

VS/C# Equivalent of Java/Eclipse "resource folder"?

While using Java in Eclipse IDE, one can add a folder to the "Build Path" using the "Add Class Folder" option in the "Libraries" tab, which allows the resources in that folder to get compiled inside the application's jar file, rather than outside or not at all.
.
With this, one can get the resources inside the folder as a URL via the Class.getResource(String name)method. I am already informed about C#'s equivalent: Assembly.GetManifestResourceStream(string name) or Assembly.GetManifestResourceInfo(string resourceName) methods, but I am not aware of C#'s "Build Path" equivalence in Visual Studio (I am using 2019, if you wished to know). Could somebody please explain how I would accomplish Java's build path resource folder in C#?
(Note that I am looking to create a resource folder where anything put inside the folder would be considered an application resource. I am not looking for a way to add one or more resource files individually.)
Any replies would be greatly appreciated! :)
After a little research, I had found a solution for this problem. There are in fact two possible solutions to this issue.
.NET Core Solution
The first involves editing the .csproj file of your C# project. This solution is only available in .Net Core.
You can add this code snippet to your file and change the {PATH_TO_RESOUCE_FOLDER_HERE} folder to your desired folder.
<ItemGroup>
<EmbeddedResource Include="{PATH_TO_RESOUCE_FOLDER_HERE}\**" />
</ItemGroup>
Now any item placed in that folder will be considered an embedded resource Assembly.GetManifestResourceStream(string name) method.
Regular .NET Solution
The second method involves using a .resx file to encapsulate all of your resources
In Visual Studio 2019, you can create a .resx file by right clicking on the location in your project where you wish to add the file to, and navigating to Add > New Item (you may also press Ctrl+Shift+A). You can now navigate to the item that quotes "Resources File" and select it. You can now use this GUI to insert your resources (for a deeper explanation, click on this or this link. For use cases, see this MSDN).
The "Resources File" option
Note that this solution will also work in .NET Core.
I hope this answer helped you as much as it did me! :)
You just create a folder and name it as you like it, say 'Resources'. Add any file you want in there to be treated as a resource by your application.
Then navigate to the properties of every resource file (you can press F4) and in the menu you can choose what you want the compiler do with that file (Compile Action is the option name if I remember well). There you select the type as a resource, the namespace (your Build Path), and whether you like the file to be copied every time you compile your application, and so on.

LNK1181 cannot open input file. space error?

I am having an compile error while trying to build my Windows Forms Project.
My solution contains:
2 c# projects (one that creates a binary & one that is just a class with functions)
2 C++ projects (imported from another solution)
After import I had to re-reference the "Include Directorys" in the (project)Settings->VC++ Directories
These 2 solutions work but Im trying to have one solution instead of 2 ( them toghether. After import I had to re-reference the "Include Directorys" in the (project)Settings->VC++ Directories
And now I am getting this error:
Error: LNK1181 cannot open input file
"C:\SDK\Bin\x64 Release\\VS2017-PC.lib"
There are 3 problems with this link:
It contains a double backslach
It has a folder that is missing (C:\PC)
There is the name "Release" instead of debug
The path should look like this:
'C:\PC\SDK\bin\x64 debug\VS2017-PC.lib'
I think it is because my folder "x64 debug" contains a space and is creating this error. But I dont know how to rename and refresh the paths correctly inside the solution and I dont even know if that would really fix this error.
Image of project Property Pages
The solution was to create the missing folder.
For some reason Visual studio didnt create "x64 debug" in the right directory.

Visual Studio 2015, can't change access modifier of new resources files

I'm trying to create new resources files in VS2015. I created them fine, but when I try to change the "Access Modifier", the dropdown is disabled...
Any ideas?
I'm working in a ASP.NET MVC 6 (ASP.NET5). The project is a Class Library, but I have tested in Web Project with same results.
Thanks!!
Edit: Added Properties window
Can you check the property of your file and verify if Custom Tool is ResXFileCodeGenerator ? If it's GlobalResourceProxyGenerator, the dropdown will be disabled.
I had the same problem but I found this easy solution Visual Studio's Access Modifier drop down option is disabled for resource file
To summarize:
Right click on your file resource, choose Properties (Alt+Enter)
Change Build Action to Embedded Resource
Change Custom Tool to PublicResXFileCodeGenerator
A) In Asp.net Core projects
This problem is a known bug in Asp.net Core projects and access modifier is on public by default and you can not change it. It will be solved by asp.net core team next updates but if you need internal access modifier you can use my temporary solution:
Add your all items by the resource designer in your Resource.resx and save it
In the solution explorer expand the Resource.resx tree and open Resource.Designer.cs
Replace all public strings in it with internal and save it
Note: every time you save the Resource.resx file you should do the step 3 again.
Finally you should have a Resource.Designer.cs file with access modifiers like this:
Also check the namespace in Resource.Designer.cs file. it should be a appropriate namespace. Sync with your project namespace.
B) In Normal Asp.net projects
If you have not CustomTool property in the Properties panel for your resource (.resx) file to change it to
PublicResXFileCodeGenerator and solve the problem
Then you should change some settings in your project (.csproj) file manually. It's so easy, just follow my instructions:
Right click on your project in solution explorer and select Unload Project
Right click again on it and select Edit .....csproj
In the opened .csproj file, find the .resx string, you will see a block of settings there. That is something like bellow codes.
Change it to something like the following code (include
PublicResXFileCodeGenerator):
.
<EmbeddedResource Include="MyResourceFile.resx">
<SubType>Designer</SubType>
<Generator>PublicResXFileCodeGenerator</Generator> <!--important line-->
<LastGenOutput>MyResourceFile.Designer.cs</LastGenOutput>
</EmbeddedResource>
Save the edited .csproj file
Right click again on your project in the solution explorer and select Reload project
Now open your .resx file and enjoy ;)
Note: use your resource file name instead of MyResourceFile
I've been having a similar problem.
This appears to be a known issue: https://github.com/aspnet/Tooling/issues/339

Could not find file 'obj\Debug\OldProjectName.csproj.FileListAbsolute.txt

I'm trying to publish project (tools vs2010), but cannot all the time getting the error below.
I paste to my projects files from another project and then I changed namespace (OldProjectName) to the parent project (NewProjectName). But it still getting information from somewhere about old project.
I cleaned solution, builded, rebuilded. Closed and reopened again and all the time the same error.
I'm able to build project but publish it.
Any ideas what can cause the problem?
Error 1 Copying file
obj\Debug\OldProjectName.csproj.FileListAbsolute.txt to
obj\Debug\Package\PackageTmp\obj\Debug\OldProjectName.csproj.FileListAbsolute.txt
failed. Could not find file
'obj\Debug\OldProjectName.csproj.FileListAbsolute.txt'. 0 0 NewProjectName
Open your .csproj file in notepad
Find "obj\Debug\OldProjectName.csproj.FileListAbsolute.txt"
Remove that line and save it
Open your project and try to publish it and this time you will be succeeded.
Note: if you are getting any more file like .pdb remove that as well.
Hope it will help you
Make sure the obj folder is not read only, if so change read only property of this folder to false. this worked for me.
Check the permissions to the folder obj\Debug\ if you give it write permissions, the error would go away.
Check if the folders "bin" and "obj" are checked-in to source control, if so delete those two folders in source control. There is no need to check-in these two folders to source folders. Also make sure that these folders "obj" and "bin" are deleted from your hard disk, they will be created again after a build.
Hope this will fix your issue.
It is your responsibility to make copies so you can go back to one.
Open your project file (vb/cs)proj with a notepad, and search for the missing files.
In my case I got this error when I tried to publish the project and certain files were not found.
Each publish attempt I got another file name, after checking that the file actually didn't exist in the project, I removed it from the project file, manually.
Then publish succeeded.
Delete the obj folder and build again.
Ref: http://forums.asp.net/t/1402005.aspx
Like many others these files were read only and needed to be deleted or actually able to be overwritten by VS. However, as may be the case for many others, the problem was because these files were checked in to source control. Your bin and obj folders should not be in source control. Mark them for delete and submit the changelist.
One exception to the rule is for the bin folder could be dll files that are not .Net compatible. Such as a C/C++ dll that you are using through a .Net wrapper dll. I mark them as content so that they get published and check them into source control.
I too had this problem. I resolved this by deleting files inside project bin folder (.dll and .pdb) and closed and re-opened VS .
The file named FileListAbsolute.txt was deleted from the folder obj/debug. Visual Studio can automatically recreate the file and others in the obj/debug for you.
For VS to recreate it, set the configuration of the solution and the project to debug mode. Then rebuild your solution.
To change the configuration mode to debug, from the solution explorer, right-click on the solution name and select Properties.
Select Configuration under Configuration Properties. Then select Debug from the dropdown list.
Click Apply and OK. Ensure that in Configuration Manager, the configuration mode is also a debug mode.
Then rebuild your solution.
For me using solution here: Certain Razor views not publishing
Excluding the views folder and re-including fixed it for me. So it's possible for anyone else experiencing this it may be as simple as excluding and then including the file/folder in question of your project.
I encountered this bug using VS2017 with a solution stored in OneDrive.I suspected OneDrive's sync mechanism to be the root cause of this.
When I tried to reproduce using VS2019 however it did not reappear. Looks solved in between these versions.

Typed dataset not recognized when moved to another project

I moved a typed dataset from one project to an ASP Web Application project. I put the typed dataset into one of the existing directories as it was in the App_Code directory of the previous site but don't see the option to create that asp.net folder in this project.
Now, when I try to instantiate the typed dataset, the compiler says 'The type or namespace name '' could not be found (are you missing a using directive or an assembly reference?)'.
Thoughts?
You may need to re-gen the DataSet. When you move the .xsd, you've only moved the xml layout of the DataSet.
Delete any generated code file, open the xsd, move something, and then save it. The save operation calls the generator. Or you can right-click on the .xsd file and call the generator directly.
I moved my web site to a Web Application Project and experienced the same issues. I took the approach mentioned in the first answer and was able to get the project to compile eventually.
I would like to add a little more detail to the first answer.
To be explicit: I first deleted all of the files associated with the xsd file except for the xsd file itself (the xss, xsc, cs, ...). I then right-clicked on the xsd file, selecting "View Designer" and then "View Code", and then "Run Custom Tool". All of the files were re-gened and the references compiled.
Make sure the compiler knows it's a dataset and not just an Xml file. Select the DataSet.xsd in Solution Explorer, then in the Project window ensure that "Custom Tool" is set to MSDataSetGenerator.
After that, instead of guessing, open up the dll file in Reflector and look for your DataSet class. Make sure it's in the namespace you think it is.
In Visual Studio 2015, what I did was
Before I right-click the added dataset to Include in project, I deleted the .xss and .xsc files and left the rest.
I then right-click the .xsd file and included in the project and problem solved.
Hope I solved someone's problem.
You have included the "using namespace" statement in the new code?

Categories