VS2019 CS1566 when project has an licx file init - c#

Recently upgraded to Visual Studio 2019. If there is a licenses.licx license file present in the project properties folder, the following error occurs at build time:
error CS1566: Error reading resource 'MyProgram.exe.licenses' --
'Could not find file
'C:\Sourcecodefolder\obj\x64\Debug\MyProgram.exe.licenses'.'
I tried setting "Copy to Output Directory" to "Copy always", on the .licx file. but that didn't help.
If I delete the license file, the app builds OK. As soon as I open a Windows form, Telerik create a new .licx file and adds it to the project. So every time I open a form in designer view, I have to go delete the .licx file before it will build. Thanks for any help.

I automate that by installing EmptyLicensesLicx NuGet package, which will make sure there's always an empty Licenses.licx file in your project, before it gets compiled (which is all you really need).

Related

Why Visual studio 2017 is publishing entire solution?

Installed VS2017 from scratch and moved existing vb.net, c# webform solutions to the new laptop.
First issue was related to "The target GatherAllFilesToPublish does not exist" error which I fixed by opening vbproj (or csproj on another project) and add this line:
<Target Name="GatherAllFilesToPublish">
</Target>
Now I was able to publish with no errors but the output in the destination folder is the entire solution including .aspx.vb or .aspx.cs files, .Global.asax.vb, .aspx.designer.vb files etc.
Checked the project Package/Publish Web settings and Items to deploy is set to "Only files needed to run this application".
Still the publishing copies the entire solution instead only the aspx, dll and only what is needed. Any idea what I am doing wrong ?
Edit csprojfile,in that file change vs version of your old project to vs 2015 in property group.save the file and rebuild .it will work properly.

"PDB does not match image" error in C# VS2010 project

I've been using a library in my code base for a while now, and I wanted to debug right into the library level. To do that, I downloaded the source code and included the project as an existing project into my C# solution. I then had my other projects reference that project instead of the downloaded .DLL.
Once the project was referenced instead of the DLL, I ran my solution through the debugger and tried to step into a function call that would have called into the external project, but it stepped right over it. While debugging, I opened up the "Modules" window and saw that the DLL's Symbol Status read "PDB does not match image", which is the likely cause of not being able to debug this project.
My question is simple, why does the PDB not match the image if my project is directly referencing the .csproj file as a reference? There should never be any ambiguity as to what version to run.
I've run into this issue before when I have another project open that also references the DLL and uses its debug info (PDB). Basically the other project puts a file lock on the PDB in the referenced project and when you compile or debug the referenced project, it quietly fails to generate an up-to-date PDB file.
If this is what is going on, make sure you have no other apps running or instances of VS open that reference your DLL, and then seek out and delete all copies of the PDB from beneath the BIN and OBJ folders, then recompile it.
I hope that helps.
Sometimes it happens because you might have build the project as a release.
Right click on the solution and click on "Batch Build" > Check all your projects and click "Clean"
For me this happened for an Excel Add-In. I went to the modules window to see why it wasn't loading for my dll. I looked at the folder where the .dll was located and went to that location. There was an .ini file in that location. Opening it revealed the install location of my application, which turned out to be in "C:\Program Files\" as opposed to the bin\debug location of my project.
Basically I had an old version of the add-in already installed that was getting loaded up upon me trying to debug the project. I uninstalled the old project, deleted the old .dll location in "C:\Users[user]\AppData\Local\assembly\etc..." and voila, the debugger loaded up the newly compiled dll.
Faced same issue, it was due to old assembly and latest PDB. There was mismatch between both.
The assembly was built properly, but again my post build dll copy script was overwriting it with older one.
Removing the dll from post build script resolved issue.
Need to ensure that dll or pdb are up to date when debugging finally commences.
This happened to me today while I was trying to debug notepad++ dll plugin , I had to change build output directory to notepad++'s plugins directory and set the Debugger to launch notepad++ instead of the current project dll to proceed with set breakpoint. This had me nuts as Visual Studio 2019 was telling me that SYMBOLS were not loaded for the plugin dll which I was trying to debug.
Finally checking the modified date and time as others here suggested, made me realize the pdb was not up to date with the the build output dll timestamp. I tried rebuilding the solution but the pdb generated has same older timestamp though I delete them manually and initiate build. So all I had to do was to make a change in the source code by deleting a white space and rebuild. Voila! this time I got the debugger to load the symbols for my dll automatically and hit the set breakpoint.
Maybe cleaning the solution also might have worked.

How to include other files to the output directory in C# upon build?

I have some library files needed for my application to work.
My application has a setup and deployment included.
I already know that in order for a library file to be added to the output directory of the application when installing, I just have to reference those libraries inside the .NET IDE before building... the only problem is that these libraries can't be referenced... So I need to be able to copy these libraries to the installation directory of my application... At the moment, I am copying these libraries manually...
Addendum
I also did try to add these library files as an Existing Item to my project and marked each library files' Copy to Output Directory to Copy if newer on their properties but still not getting the solution I want.
Update 1
Thanks for you help guys it helped me solve my problem, I managed to make the solutions you posted work except for one... #Matthew Watson's post.. I even managed to find a solution too so I wanted to share it with you also.
Heres what I did:
I opened the setup and deployment project in my application.
Under the Application Folder Tree, on it's right side, I right clicked..
then clicked Add..
then clicked File
and then browsed for the files I wanted to add to the installation directory
and click open.
But out of curiosity...I am still trying to make what #Matthew Watson posted work...
Update 2
I forgot to update this post yesterday, I already manage to make Matthew Watson's solution worked yesterday. Thank you again for all your help guys.
You can add files to your project and select their properties: "Build Action" as "Content" and "Copy to output directory" as "Copy Always" or Copy if Newer (the latter is preferable because otherwise the project rebuilds fully every time you build it).
Then those files will be copied to your output folder.
This is better than using a post build step because Visual Studio will know that the files are part of the project. (That affects things like ClickOnce applications which need to know what files to add to the clickonce data.)
You will also be more easily able to see which files are in the project because they will be listed with the source code files rather than hidden in a post-build step. And also Source Control can be used with them more easily.
Once you have added "Content" files to your project, you will be able to add them to a Visual Studio 2010 Setup and Deployment project as follows:
Go into your Setup project and add to your "Application Folder" output the Project Output called "Content Files". If you right-click the Content Files after adding them you can select "outputs" and see what it's going to copy.
Note that Setup and Deployment projects are NOT supported in Visual Studio 2012.
You can use Visual Studio Post Build Event - Copy to Relative Directory Location. Which are basically scripts that are executed on build of specified project.
So you can use it to copy binaries you need, before actually running your application.

Deploy external file in c# solution with clickonce

I've a problem with Visual Studio Express 2010 c# edition.
I've a project that reference a DLL. This DLL has an external Excel file marked as
Build Action = Content
Copy to Output Directory = Copy Always
When I build the solution, this Excel file is correctly copied into BIN\release solution folder.
BUT if I try to deploy the same solution, with Publish wizard, the Excel file is not copied in the install directory.
Please, could anyone help me?
Open the Publish properties for your ClickOnce project. Then click on the 'Application Files ...' button. That launches a dialog where you can control which files are being included in the publishing package.
In order for your XLSX file (or any other non build file) to appear in that dialog you need to mark is as 'Content' in the Build Action of the properties window.
Are you saying that the Excel file is referenced only by the dll you are including in your project? That is a secondary reference, and ClickOnce will not see it and automatically include the file.
First, on your dll, I'm assuming it is referenced directly by your project. If so, then be sure you have added it to your project and set the Build Action to "none" and "copy to output directory" to "do not copy". Then delete your reference to it and re-add it, pointing it to the version now included in your project. Set the "copy local" property to "true". This will ensure the dll itself gets deployed correctly.
For the Excel file, you are going to have to add it to your project. Set the build action to "content" and set "copy to output directory" as "copy always". It will not be included automatically because it is a secondary reference to the ClickOnce app, not a direct/primary reference like the dll is.
Try to include this file into solution and set "Copy to Output Directory" to "Copy always"
It appears your file is not listed in the "PublishFiles" list. Open the Projects Properties, go to "Publish" Tab, click on "Application Files" button, make sure you see the DLL file in the list of files with Publish Status as "Include".
You could avoid the problem by inserting the Excel file as a resource, then writing it out like this:
File.WriteAllBytes(DestinationFileName, Properties.Resources.MyResourceFile);
I'm making an assumption that the Excel file is some kind of template you are using to build an output file from.

unable to compile the c#.net project ..getting error "resources was specified more than once "

The item "obj\Debug.resources" was specified more than once in the "Resources" parameter + c#.net
Did you by any chance copy/paste a Form?
the error tells you there is more then 1 class in the project with the same name.
For the others: the problem is reproducable using the following steps:
create a new smart device project.
copy/paste Form1. (so Visual Studio creates the files "Copy of Form1.*)
Build.
sure you don't have any duplicates?
If you don't have anything relevant in your resx files just delete them. VS will regenerate them and your project will compile. Do this only for the forms that you copy-pasted.
VS 2005?
See this: http://social.msdn.microsoft.com/forums/en-US/vbide/thread/4048e49f-3a6f-46ce-9efd-d046f7041e2e/
In your project file, if you open it in notepad, it will likely have the item listed twice. You can edit the project file or delete the resource file. If that doesn't help, also check the properties for your files, and make sure that they are correct, and have "Build Action" set to "Embedded Resource", "Copy to Output Directory" set to "Do not copy" for your resx files.
Try to clean up the project and then rebuild it again.

Categories