EAZfuscator not working automatically - c#

I have a C# 2010 WinForms application using .Net Framework 4.
I am using Eazfuscator.NET to obfuscate this application. If I obfuscate the executable manually, everything works fine.
When I try to make the program obfuscate itself on every build by dragging the project onto the green part, everything works fine and this is output:
Protecting project 'Roster Manager.csproj'... done
Protected project will be obfuscated automatically during the build in Release configuration
Please restart Visual Studio to complete the installation of Eazfuscator.NET
After that, I close VS, start it again, clean the solution, rebuild it and run it. The program works but it is not obfuscated, as proved by decompiling it using Reflector 7.
I am building it in Release as requested by the program.
Searching the web didn't help so maybe if someone ran into this problem before might have a fix to this issue.

Eazfuscator add this line to the PostBuildEvent (Word Wrapped for legibility, but it is one line) of your project. (Right click on Project -> Properties -> Build Events.)
if /I "$(ConfigurationName)" == "Release" Eazfuscator.NET.exe "$(TargetPath)"
--msbuild-project-path "$(ProjectPath)" --msbuild-project-configuration "$(ConfigurationName)"
--msbuild-project-platform "$(PlatformName)" --msbuild-solution-path
"$(SolutionPath)" -n --newline-flush -v 3.2
Check if it is present and if your release configuration is really called "Release".

Finally managed to fix it. Seems that disabling the User Account Control resolves the issue.
A quick Google search will give more details into how to do this.

If you're using a version control system like TFS, .csproj file may be locked.
So you'll have to unlock file by checking it out or unchecking "Read-only" box from file properties.

Related

Could not locate .NET Core project. Assets were not generated

I just started learning C# a couple hours ago, but have since run into this error.
Ctrl + Shift + P
.NET:Generate Assets for Build and Debug
But when I click it, an error pops up bottom right of the window:
Could not locate .NET Core project. Assets were not generated.
Restarting VS Code solved the problem in my case.
This same thing started happening to me on my mac on vscode. For me, it was because I didn't add my dotnet project to my solution file after I created the solution file and project.
This is essentially how I created my project:
Create empty project folder mkdir RecipeApp && cd RecipeApp
Add Solution File to Project (uses the name of containing folder) dotnet new sln
Create Backend .NET API dotnet new webapi -o API
Then this is the part I forgot to do (which actually solved a few other problems I was having, like I couldn't use the CMD + . feature to auto import classes and assets etc, too):
Add the sub project to the solution file dotnet sln add API
After I added the API subproject to the solution file, I could open the main top level project folder in vscode, and everything started working again.
This issue could be because the launch.json, which ideally should have been populated with the necessary details isn't generated in case. This issue seems to be linked to Omnisharp. If you go through the issue, you understand the root cause more clearly. You may need to perform the steps mentioned in this comment to get around the issue. These steps involve re-configuring the C# extension inside of your VS Code instance.
Alternately, ensure that all the folders which the extensions uses have appropriate access.
If the issue is also involving task.json, take a look at this answer
In my way helped to change the folder name to a name without spaces.
What I recommend doing is pressing "Run" then start debugging, which should open up a launch.json. If you open it, it will have about 17 warnings and then you can delete the warnings. Then, you press f5, which will give you an option to open a tasks.json. Do that and configure all of the tasks for running your project and it should work.
for me it helped to open the project with opening project_name.csproj with vs-code instead of loading the folder
In my case I just uninstall the c# extension and reload the vscode, after I install again (The vscode will ask to install some assets and somethings that miss in the project too).
Changing extension path manually helped me

Visual Studio 2013 is running old code

I have searched and found other topics on this, but none of the solutions seem to work for me. Visual Studio is running old code in debug mode and release mode. If I go to the actual directory and launch the exe, it is the latest code. It is a XAML project.
Things I have tried:
1) Deleted bin and obj folders
2) Rebuilt solution
3) Cleaned solution
4) Made sure the project is set to build in Configuration Manager
Update: I tried adding a new configuration in Configuration Manager. The path is totally different, and it still running the old code. The exe built with the new config is the right code when I launch it manually, but it seems like visual studio is running a cached version of the exe.
Another gotcha I see a lot - be careful with shortcuts. If you are opening the solution via Recent Projects or another shortcut, try opening it via File -> Open or clicking on the solution file itself instead. I see a lot of developers looking at old code or the wrong branch because of this.
Can also try changing the assembly version number. Every once in awhile that will somehow make a difference.
I am not sure what exactly helped, but one thing is certain:
i marked .js file properties "Build action" as "Compile".
Tryed to deploy (got an error of course), and changed it back to "Content".
Rebuild, deploy, run debugger and FINALY it works on my current code.
The Error is back on my "new old" code
What i do is:
click "Continue", go to opened IE window with my page\site, press CTRL + F5,
and what i see?
My new current code inside VS debugger...
Error is gone

Build Failed. See the build log for detail

I create a new project, click compile, and get this error:
Build Failed. See the build log for details.
In the build log there is only this:
Building: FirstProgram (Debug|x86)
---------------------- Done ----------------------
Build failed.
Build: 1 error, 0 warnings
Here is what I see:
What causes this error and how do I fix it?
Lots of times dealing with this error. I just closed and reopened. It happens every time I add a solution and then delete it. I think Xamarin Ide is not a really good Ide, not in Mac at least.
In my case, i did`t Indy (or higher) License.
When i started trial period, the problem was solved.
I got the same error when trying to build. Without having noticed I had been logged out of my account, which caused the error. Curious that I wasn't prompted to relog or given information that I wasn't logged in.
Though this is an old post, maybe this could help someone.
In my case, using Xamarin Studio 6.1.4 (build 1), I unchecked
the 'Use MsBuild engine ...' check box under Project Options > Build > General and
the problem disappeared.
I searched for solution online for similar problem, but none solved my problem, then I tried this:
Tools >>> Options >>> Projects and Solutions >>> Build and Run
Then I changed MSBuild output and MSBuild log to Detailed.
Rebuild and the error message will show.
cd into the project path, and hit msbuild on it.
You will then see the error details in the console STDOUT.
I had the same problem after upgrading Xamarin, and in my case it happened even for a x86/desktop Console Application. Turned out to be because I didn't have 4.5.1, which was required by the newer version (I had only 4.5 I think).
I found this entry in the log:
Unregistered TargetFramework '.NETFramework,Version=v4.5.1' is being requested from SystemAssemblyService, returning empty TargetFramework
After googing this error I found https://stackoverflow.com/a/38102386/492336, and the solution was to download .NET 4.5.1 and it worked after that!
I just ran into the same problem using Visual Studio Community for Mac. The system was out of disk space. Freeing up some disk allowed a build to complete successfully.
Try the following options from Build menu:
Clean All
Rebuild All
Then build it again.
If won't help, check your log files for details by going to Help menu and Open Log Directory.
For example by dragging & dropping the log folder into newly opened Terminal window, and run:
tail -f *.log
then run the build again and check the reported logs. Hit Control-C on Terminal when finished.
For better visibility, run:
tail -f *.log | grep -C5 -i error
You can also try to clear cache folder of VisualStudio, e.g.:
$ lsof -p $(pgrep VisualStudio)
$ rm -fr ~/Library/Caches/com.microsoft.visual-studio
I downloaded and installed the packages shown below in the order listed:
JDK 1.6: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u31-download-1501634.html Please choose the jdk-6u31-windows-i586.exe installer from the list above.
Android SDK: http://dl.google.com/android/installer_r20-windows.exe After the main installer is done, please open the SDK Manager and install the following platform APIs: 7,8,10,12,14
Mono for Android SDK: http://download.xamarin.com/MonoforAndroid/Windows/mono-android-4.4.55.104956787.msi
Reboot Xamarin.
Try building your project from the Powershell command line.
dotnet build
Then, build errors will appear in the command line output.
I encountered this issue today in Visual Studio for Mac 2022 with a Xamarin Forms 5 project. In my case, going to the Solution properties, under Build → General, and unchecking "Build with MSBuild on Mono" worked.
(This might be similar in spirit as #JackGriffin's answer, but it seems to be a solution property rather than a project property.)

the source file is different from when the module was built

This is driving me crazy.
I have a rather large project that I am trying to modify. I noticed earlier that when I typed DbCommand, visual studio did not do any syntax highlighting on it, and I am using using System.Data.Common.
Even though nothing was highlighted, the project seemed to be running fine in my browser. So I decided to run the debugger to see if things were really working as they should be.
Every time the class that didn't do the highlighting is called I get the "the source file is different from when the module was built" message.
I cleaned the solution and rebuilt it several times, deleted tmp files, followed all the directions here Getting "The source file is different from when the module was built.", restarted the web server and still it tells me the source files are different when they clearly are not.
I cannot test any of the code I have written today because of this.
How can the source be different than the binary when I just complied
it?
Is there any way to knock some sense into visual studio, or am
I just missing something?
I got this issue running a console app where the source that was different was the source that had the entry-point (static void Main). Deleting the bin and obj directories and doing a full rebuild seemed to correct this, but every time I made a code change, it would go out-of-date again.
The reason I found for this was:
I had checked "Only build startup projects and dependencies on Run" (Tools -> Options -> Projects and Solutions -> Build and Run)
In Configuration Manager, my start-up project didn't have "Build" checked
(For #2 -> accessible via the toolbar under the 'Debug/Release' drop down list.)
I was just having this same problem, my projects were all in the same solution so they were using Project to Project references, so as one changed the others should have been updated. However it was not the case, I tried to build, rebuild, close VS2010, pulled a new copy from our source control. None of this worked, what I finally ended up trying was right clicking on the project and rebuilding each project individually. That updated the .dlls and .pdb files so I could debug through.
The issue here is that your dll and or your pdb files are not in sync.
Follow these steps
Just delete the bin directory from the project where the DLL is generated.
Re-build the project.
Remove reference from the project that make reference to the DLL.
Include again the reference.
Enjoy.
In addition to these answers I had the same issue while replacing new DLLs with old ones because of the wrong path. If you are still getting this error you may not refer the wrong path for the DLLs. Go to IIS manager and click the website which uses your DLLs. On the right window click Advanced Settings and go to path of the Physical Path folder on File Explorer and be sure that you are using this folder to replace your DLLs.
Some things for you to check:
Have you double checked your project references?
Do you have a Visual Studio started web server still running? Check the system tray and look for a page with a cog icon (you may have more than one):
(source: msdn.com)
Right click and close/exit it. You may have more than one. Can you debug your changes now?
Are you running the debug version but have only built the release version (or vice versa)?
Did the compile actually succeed? I know I've clicked through the "there were errors, do you want to continue anyway?" message a couple of times without realising.
With web services, the problem can be caused by using the Visual Studio "View in Browser" command. This places the service's DLL and PDB files in the bin and obj folders. When stepping into the web service from a client, somehow Visual Studio uses the PDB in the bin (or obj) folder, but it uses the DLL in the project's output build folder. There are a couple workarounds:
Try deleting the DLL and PDB files in the web service bin and obj files.
Try clicking "View in Browser" in Visual Studio.
If you previously got the source file mismatch error, Visual Studio might have added the filename to a black list. Check your solution properties. Choose "Common Properties -> Debug Source Files" on the left side of the dialog box. If your web service source files appear in the field "Do not look for these source files", delete them.
Unload the project that has the file that is causing the error.
Reload the project.
Fixed
I just had this issue.
I tried all the above, but only this worked:
delete the .pdb file for the solution.
delete the offending .obj files (for the file being reported out of sync)
build the solution.
This fixed the issue for all builds moving forward for me.
In Visual Studio 2017 deleting the hidden .vs folder in the resolved this issue for me.
This is how I fixed the problem in Visual Studio 2010:
1) Change the 'Solutions Configurations' option from "Debug" to "Release"
2) Start debugging
3) Stop debugging and switch the 'Solutions Configurations' option back to "Debug"
This worked for me. Step 3 is optional - it was working fine when I changed it to "Release" but I wanted to change it back.
My solution:
I had included an existing project from a different solution in a new solution file.
I did not notice that when the existing project was rebuilt, it was putting the final output into the NEW solution's output directory. I had a linker path defined to look into the OLD solution's output directory.
Switching my project to search in the new solution's output directory fixed this issue for me.
I had this problem, and it turns out I was running my console application as a windows application. Switching the output type back to console fixed the issue.
I had the same problem. To fix it I used the "Release Mode" to debug in VS2013. Which is sufficient for me, because I'm working in a node js\c++ addon.
My problem was that I had two projects in my solution. The second one was a test project used to call the first one. I had picked the path to the references from the bin folder's release folder.
So whenever I made a change to the first project's code and rebuilt it, it would update the dlls in the debug folder but the calling project was pointing to the release folder, giving me the error, "the source file is different from when the module was built."
Once I deleted the reference to the main project's dll in the release folder and set it to the dll in the debug folder, the issue went away.
In my case, the #Eliott's answer doesn't work.
To solve this problem I had Exclude/Include From Project my deficient file, andalso Clean and Rebuild the solution.
After these actions, my file with my last modifications and the debugger are restored.
I hope this help.
solution:-
the problem is:-
if your some projects in a solution , refer to some other projects,
then sometimes the dll of some projects, will not update automatically, whenever you build the solution,
some projects will have previous build dlls, not latest dlls
you have to go manually and copy the dll of latest build project into referenced project
I was using Visual Studio 2013 and I had an existing project under source control.
I had downloaded a fresh copy from source control to a new directory.
After making changes to the fresh copy, when building I received the error in question.
My solution:
1) Open Documents\IISExpress\config\applicationhost.config
2) Update virtualDirectory node with directory to the fresh copy and save.
My problem was that I had a webservice in the project and I changed the build path.
Restoring the default build path solved my issue.
I had this same problem and I followed the majority of the guidance in the other answers posted here, nothing seemed to work for me.
I eventually opened IIS and recycled the application pool for my web application. I have IIS version 8.5.9600, I right-clicked my web application, then: Deploy > Recycle > Recycle application pool > OK.
That seems to have fixed it, breakpoints now being hit as expected. I think that doing this along with deleting the bin and obj folders helped my situation.
Good luck!
I know this is an old question but I just had the same problem and wanted to post here in case it helps someone else. I got a new computer and the IT dept merged my old computer with the new one. When I set up TFS, I mapped a different local path than what I was previously using, to an additional internal drive. The old path still existed from the merged data on my hard drive so I could still build and run. My IIS paths were also pointing to the old directory. Once I updated IIS to the correct path, I was able to debug just fine. I also deleted the old directory for good measure.
I also experienced that. I just open the obj folder on the project and then open the debug folder delete the .pdb file and that's all.
This error also happens if you try to make changes to a source file that is not part of the project.
I was debugging a method from a .dll of another one of my projects, where Visual Studio had quite helpfully loaded the source because the .dll had been built on the same machine and it knew the path to the source. Obviously, changing such a file isn't going to do anything unless you rebuild the referenced project.
Delete all breakpoints.
Rebuild.
Done
At Visual Studio 2015, using C++, what fixed for me the the source file is different from when the module was built problem was
restart Visual Studio.
Check if the location you pointed to using mex() in Matlab is correct (contains lib and obj files which are modified to the last date you compiled the library in Visual studio).
If this is not the case:
Make sure you are compiling Visual studio in a mode that saves .lib files :
properties -> Config properties -> General -> Config type -> static library
properties -> Config properties -> General -> Target extension=.lib (instead of exe)
Make sure the output and intermediate directories match the Matlab directory in
properties -> Config properties -> General -> Output directory
properties -> Config properties -> General -> Intermediate directory
I get this issue when debugging sometimes w/ Visual Studio but when the application is served by IIS. (we have to develop in this form for some complicated reasons that have to do with how the original developer setup this project.)
When I change the file and rebuild, that fixes it a lot of the time. I know that sounds silly, but I was just trying to debug some code to see why it's doing something weird when I haven't changed it in a while, and I tried a dozen things from this page, but it was fixed just by changing the file..
In my case, the problem was that the debugger exe path was pointing to a net5.0 bin folder. I am using net6.0, so I should've updated the exe path back when I updated the target framework. Works fine now.
Debug-> start without debugging.
This option worked for me. Hope this helps!

Unable to copy a file from obj\Debug to bin\Debug

I have a project in C# and I get this error every time I try to compile the project:
(Unable to copy file "obj\Debug\Project1.exe" to "bin\Debug\Project1.exe". The process cannot access the file 'bin\Debug\Project1.exe' because it is being used by another process.)
So I have to close the process from the task manager. My project is only one form and there is no multi-threading.
What is the solution (without restarting VS or killing the process)?
This should work.
Go to your project properties.
Inside Build Events, under Pre-build event command line, add these two lines of code:
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
#Udpate: Since the time I was first posting this 'answer', I tend to another explanation to the problem. The issue since than happened more and more often outside of Visual Studio also - while trying to copy an .exe file from one folder to another. While in the first place Windows did not allow to copy(!) an .exe file (it was first asking me for administrative rights but refused to copy it afterwards anyway) it still showed up in the explorer. But after a while - without any further action taken, it disappeared magically. Just like the problem in the question always seems to solve itself after a while. So i assume, the problem is more related to a delayed deletion of the project output file and less a buggy VS. I apologize for any unjustified suspicion. :|
This gives the search for a solution a complete different direction, I guess. Did find that link and will update on any progress:
https://superuser.com/questions/234569/windows-7-delayed-file-delete
========================================================================
This is a known bug in VS. I discovered it very often - mostly in VS2010 (with/without SP1). Several "solutions" are recommended. Some of them, which kind of helped for me:
Delete the .suo file in your project dir. Eventually need to create your whole solution from scratch.
Close any Windows Form Designers may remain open.
Use a prebuild script, which deletes the target from the output dir.
Disable the VS hosting process.
None of these really fixes the bug. But it may brings the VS back to a usable state - until a true solution is provided by MS (if ever will).
http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/cea5e4b2-5b33-453c-bffb-8da9f1a1fa4a
http://social.msdn.microsoft.com/Forums/en/vbide/thread/cd12f3c7-de96-4353-adce-23975e30933f
I can confirm this bug exists in VS 2012 Update 2 also.
My work-around is to:
Clean Solution (and do nothing else)
Close all open documents/files in the solution
Exit VS 2012
Run VS 2012
Build Solution
I don't know if this is relevant or not, but my project uses "Linked" in class files from other projects - it's a Silverlight 5 project and the only way to share a class that is .NET and SL compatible is to link the files.
Something to consider ... look for linked files across projects in a single solution.
This is happening because [yourProjectName].exe process is not closing after finishing debugging.
There are two solutions to this problem.
Every time you make change to application, Go to Task Manager -> Processes -> [yourProjectName].exe, end this process. You have to end this process every time you make changes to system.
Add a exit button in your application to exit window and add these line to click event
System.Diagnostics.Process.GetCurrentProcess().Kill();
Application.Exit();
If you look in the obj directory, and you don't see your .exe, it's possible that Avast! or other antivirus is deleting it. I would actually see the .exe show up and then disappear. As soon as I turned off Avast!, problem solved.
VS2010 throwing "Could not copy the file "obj\x86\Debug\[file].exe" because it was not found."
The real problem isn't the error you're getting; it's that the application isn't cleaning up after itself.
It's either holding on to references, not freeing resources, or something else that's causing the process to not end when it's being told to close. Fix up that issue and this problem will resolve itself. We can't really help you with that unless you post your code (and at this point, if you need help with that, you should start a new question).
I had to go into windows explorer and delete the bin/debug folder as well as the obj/debug folders. Then I cleaned & rebuilt the project.
Close your project
Delete bin folder
i find it work, :)
Rename the assembly to a different name to solve this issue.
After seeing a similar error in visual studios 2012 out of no where. I have found that that going to the root folder of the project and right clicking on it I unchecked read only and this error went away. Apparently TFS sometimes will made a folder read only. Hopefully this will help anyone with a similar issue. Thanks
This happened to me at VS 2010 and Win 7..
Case :
I can not Rebuild with Debug Configuration manager, but I can rebuild with Release Configuration manager
What I have tried:
Check my account type at control panel - user account --> My Account is Administrator
Set the bin folder not read only
Add security at bin folder to Everyone
stop the iis server
Stop antivirus, check ridiculous running program using task manager and ProcessExplorer
run VS as administrator
If All that way is still not working.
Then, the last way to try:
close solution
close visual studio
start - shutdown
press power button to turn on the computer
login to your account which has administrator previlege at user type
reopen solution
rebuild
that way working. All people call this way as Reset Computer
Mine got solved by:
Clean solution
Close all processes depending on VS (Current instances).
Rebuild
I had same problem, after read your answers , went to Task Manager and searched for app.exe because i believe maybe it doesn't close .
And found it , select it and do END TASK .my problem solved.
Before rebuild the solution, clear the project, stop the IIS and open the "bin" folder property. Uncheck the Read-only Attribute in general tab then rebuild.
I found that ending all msbuild.exe tasks (in Task Manager) fixed the issue with VS2012.
I struggeled with this since years.
I finally downloaded LockHunter to find out who locked the file.
In my case it was MBAM.
Once I added my project's directory to MBAMs exclusion list, I didn't have this problem anymore.
I too had the same issue. I resolved it
Closed my VS, then in Task Manager, End tasks like Microsoft VisualStudio WCF Tools, MSBuild.exe
Then open VS and clean and rebuild.
No matter what the cause of this problem is, the only working solution for me is the following:
Go to Your-Project-Properties -> Application tab(first tab) -> Change the Assembly name.
This way your app creates a new assembly file each time you change the assembly name.
Finally, after you finish to develop, you can delete all those extra assembly files and just keep the last one (main one). Non of the other solutions worked for me, except this one.
Run Visual Studio as Administrator
We recently experienced this on a WinPhone 8 project, in VS 2012 Update 2.
Inexplicably, the cause was using the Tuple type. Removing the code that used a Tuple the problem went away. Add the code back the problem returned.
This will Sound crazy, when ever i build the project the error will be displayed and the avast antivirus will show it as malicious attempt and the project does not run.i just simply disable my antivirus and build my solution again the missing .EXE file has been Created and the project has been successfully executed.
Or you can try this
Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug
I solved this by killing XDesProc which had a handle on the DLL it couldn't delete.
Well i have the same problem, my way to fix it was to stop and disable the "application experience" service in Windows.
Not a direct answer to your question..
One scenario when this can come is listed below -
If your application is under Debugging process - say by "Attach to Process" debugging, this error may come
If this error was encountered, you can proceed as the following
End the msbuild.exe task
End the explorer.exe task
Run the explorer.exe task again
for me it was the antivirus. Just add visual studio project or entire parent folder to Antivirus exclusion list or you can also add file extension as exclusion and this method worked for me in visual studio 2010/2012
Solution1:
Close the project.
Delete the bin folder.
Open the project.
Build the project.
Solution2:
Add the following code in pre-build event:
attrib -r $(OutDir)*..\* /s
This command line code will remove the ready-only attribute of "bin" folder. Now visual studio can easily delete and copy new dlls.
A very simple solution is to open the Task Manager (CTRL + ALT + DELETE), go to Processes tab and search by name the processes with your project name that are still running. Kill all the processes and go on ! :)
after day with search and build and rebuild i found that you just need to turn off turn on the visual studio its look like it catch the service in different thread
My Visual studio 2019 suddenly stops and restarts and then when i run project this error comes.
I resolve this issue by going into my project folder and delete bin and obj folder
Then clean and rebuild my project. This resolve my issue.

Categories

Resources