When converting a website to a web app, the designer creates the code
protected global::System.Web.UI.WebControls.LinqDataSource
and I get the error
namespace name 'LinqDataSource' does not exist in the namespace
'System.Web.UI.WebControls'
when I try to compile.
I tried creating a new project, making sure LinqDataSource was working by adding it from the toolbox to a webpage.
After copying my existing project into the solution as a folder it failed, turns out it doesn't like the bin folder from my previous project in a subfolder of the new project.
Related
I need to read the settings file (appsettings.json) from another project in my solution. When I use:
Directory.GetCurrentDirectory()
From within the current project, I get the following path:
{projectRootFolder}\bin\Debug\netcoreapp3.0\
My question is: How can I get to the exact same folder in another project in the same solution? Or is there a better way to access the settings file from another project within the current solution?
If I understand the problem correctly there are two misconceptions:
It has little sense to access output directory of an another project as the structure has sense in compile time only. You will not have the same structure in run-time once the application is "published".
The Directory.GetCurrentDirectory() returns the current working directory. It is just a coincidence to be set to project output directory by Visual Studio. It can be totally different directory.
It is not clear to me what exactly you are trying to achieve. I recommend using the configuration system provided by .net core to access the configuration and add that other appsettings.json as another configuration provider.
If you really need to open the settings file then the project with the settings file (A) should mark the file as "Copy to Output Directory" and the project to open the file (B) should reference the project A. So the settings file will be copied to output of the project A too.
What you're attempting to do is not possible. There's no inherent way for ASP.NET Core to know where a totally different app running in a totally different process is located.
If you need to access appsettings.json from another project, then you would need to include it as a linked file in your project, and set it to copy to output. Then, you're accessing it actually from your project (which is all you can do), but the file itself is shared.
However, this is almost always a bad idea, and usually a sign that you're doing something wrong. If you truly do need to share the settings, then what you should be doing is putting them in a distributed config provider like Azure Key Vault or similar, where both projects can independently access the settings from a common store.
I get this error and I can't start my application or edit it.
I've tried deleting the Resources folder and putting everything back and it doesn't help. I also checked my 'Resources.resx' custom tool namespace, and it's fine (uses "My.Resources").
I've tried deleting my images by moving them. It's as if the resx file is hidden from VB.
I really have no idea where to go from here :(
enter image description here
Application resources are added to Resources.resx file. It create a static property against each added resource while file are stored in a Resources folder physically on the file system however, they are embedded into application on compilation depending.
Because you have deleted the resources(images most likely) from Resources folder but application (Resources.resx) is still referencing to these files.
There are two ways to fix it.
1- Go to application resources TAB and delete all the resources & Added the back.
OR
2- Put all the resources into Resources directory. select all and include them (because you had deleted them once so, they may still present in the directory but are not included in project). if you do not see in folder(from visual studio then make sure to click show All Files button on the solution explorer.
This shows how to go to Resources TAB
This shows how to include resources which already exists in the folder (got deleted)
I have a resource file called Constants.resx which contains some strings. From the controller I am trying to access to a new string that I have just added to Constants.resx file but it is not recognized by the compiler (intellisense is not showning me the new string just added) and of course when I type it, an error is shown.
In the controller header I have added below line:
using Resources;
and to access to the new string just added I do the following:
Resources.Constants.NewString
I access to other strings in Constants.resx file using the same approach and no problem, they are recognized correctly, but not this new one.
Any ideas?
UPDATED:
My resource file for my mvc 4 app was added by selecting "Add > new item" from App_GlobalResources context menu and finally selecting "Resource file".
My resource files properties are:
Build action: Content
Copy to Output Directory: Do not copy
Custom Tool: GlobalResourceProxyGenerator
Custom Tool Namespace: (left blank)
Also I am using Visual Studio 2010 Express edition.
I can see the compiler is throwing a warning saying it cannot find the custom Tool 'GlobalResourceProxyGenerator' in the system.
You have to set the namespace of all the resource files as a common namespace like ViewResource. Then change the access modifier in the resource file as public. Now you can access those resource files.
Build action: Content
Copy to Output Directory: Do not copy
Custom Tool: GlobalResourceProxyGenerator
Custom Tool Namespace: ViewResource
Access Modifier : Public (In all resource Files)
I've noticed on a few tutorials online that when a new ASP.NET Server Control is added, it automatically includes Properties folder (containing AssemblyInfo.cs) and a References folder.
This works fine for me when creating a C# Server Control, but in VB.NET I just get a template .vb file and a Project file.
Why is this and how can I get an AssemblyInfo.vb file?
AssemblyInfo.vb file is created for every project. By default it is not displayed in the Solution/Project Explorer.
To view this file and others in Visual Studio click Project >> Show All Files menu items.
I downloaded an itextsharp DLL that I would like to use in my vb.net 2008 express application.
In which folder should it be placed?
I went into choose items in the toolbox and tried to add it but I got an error
This is what I downloaded:
http://sourceforge.net/projects/itextsharp/
You need to reference the DLL inside your project: right-click on the project in solution explorer and then select Add Reference and next select itextsharp.dll. It will then be automatically copied to the project output folder alongside with the executable (usually bin\Debug)
It shouldn't matter where the DLL is places. Download the correct compiled DLL to your computer.
Open your VB.NET solution -> Right Click -> Add Reference...
Browse your PC for the DLL you just downloaded and let Visual Studio do the rest.
Typicaly you put the dll in ANY directory and set up a reference to it. When compiling, VS adds this dll to the bin directory of the application automatically.
Something to keep in mind is that there are no objects from the DLL you can put in and use from the Toolbox; you need to programmatically create iTextSharp objects.
Like this:
Add Imports:
Imports iTextSharp.text.pdf
And in your code:
Dim writer As PdfWriter = PdfWriter.GetInstance(document, iostream)
Maybe it's better to copy the additional dll file inside your project, so that when you pull it again from git server, you don't need to copy it again.