Build error in VS 2010 - visual-studio

I am getting this error in my application
Error 1 Unable to copy file "D:\myproj\bin\Debug\myproj.dll" to "bin\Debug\myproj.dll". The process cannot access the file 'bin\Debug\myproj.dll' because it is being used by another process.
How to fix it

Your project dll is being used by another process. Either you ran your application and it didn't fully shut down (check the task manager) or some other program is trying to consume the dll in the d:\myproj\bin\debug\myproj.dll
For example, in the olden days, if you used a .Net dll in a VB6 app, and pointed to the debug dll, it would grab on to that and you'd have to shut down VB6 to free the dll.
I suspect you'll have to do something similar.
Start by checking task manager and making sure your app isn't still running.
Then close down any other apps that have a reference to your dll
If neither of those two work, close down studio and restart it

Related

Register type library during installation

I have added an automation interface to an application I wrote. The type library is stored as a resource in the application, and on startup, the application calls RegisterTypeLib to register the type library automatically.
I just discovered that this call to RegisterTypeLib only works during development, where the application is launched from Visual Studio, because Visual Studio is running as administrator, and the application inherits this. When running the debug build from the command line, or when running the application as installed by the installer, the application is not running as administrator, and the call to RegisterTypeLib fails.
So I suppose I should register the type library during installation (which would also have the nice side effect of making the automation interface available without having to run the application first). The installer is a Windows Installer project in Visual Studio.
Is it possible to do achieve the effect of RegisterTypeLib during installation (and if yes, how)? When the installer solution is open, Visual Studio shows an editor called "Registry" wher one can add keys to the registry, but there's no way I can add each key separately - I need to somehow add the entire type library with a single call, like RegisterTypeLib does.
EDIT: After manuell's hint and some research of my own, the question boils down to this:
I need to call MyApp /RegServer from the installer (which will also create other required registry keys that aren't created by RegisterTypeLib); how exactly does one do this? I added an "Install" custom action in the Visual Studio installer solution, but haven't yet found out how to trigger it.
The usal way is to let the installer launch the application with the command line arguments /regserver or /unregserver. If you use a Framework (MFC/ATL), the handling of all the registration (unregistration) steps are done automatically.
If you want to do all by your self, check the arguments to "main", and call RegisterTypeLib. The Windows installer should launch your EXE with /regserver, if it knows that's a com server.

How do I stop an instance of a custom DLL in Windows Server 2008 R2?

One of my Visual Studio projects generates a custom DLL that is run in a folder of the main web site (and the web site is a web site, not a web application, so I'm not publishing from VS - all files are copied manually). Whenever I make changes and overwrite the DLL, I don't immediately see my changes, I suspect because the web site is running the original DLL file cached in memory.
How can I identify and stop the process that is running the DLL? Even if I delete the DLL from the folder the site still runs just fine, sans my changes. I have also stopped and re-started the application pool and site in IIS.
"Back in the day" we would stop a svchost process, but I don't see anything like that in task manager.
Thanks for any help you may provide!
Mike
Go and get Process Explorer, it has a feature called DLL View that will allow you to see which DLLs are being used by which process.
Read Getting a list of DLLs currently loaded in a process for screenshots of how to enable DLL View.

Attaching to the correct process but unable to debug - No symbols have loaded error - VS 2008

I am trying to debug a web application hosted in local IIS web server. I have attached the VS debugger to the process but get the error - "The breakpoint will not currently be hit. No symbols have been loaded for the document".
I have done the following things:
Deleted the bin/obj folders
Cleaned and rebuilt the solution
Closed and reopened the solution
Things I noticed:
Opened Process Explorer and made sure I am attaching to the correct process.
Opened Debug-Windows-Modules but cannot find the project dlls and referenced dlls (Does this notify that the right process is not attached?)
Please share your suggestions. Thank you.
This error will also show up if you have attached to a process that was compiled in release mode.

Unable to find an entry point named 'GetCurrentPackageId' in DLL 'kernel32.dll' when using Visual Studio debugger

I have an ASP.NET which calls an asmx web service. It works fine on one machine with or without using the debugger in VS 2010. On another machine, it gives an error "Unable to find an entry point named 'GetCurrentPackageId' in DLL 'kernel32.dll'" in the web service constructor and when launched in the debugger. If the app is running without the debugger it runs fine. If the debugger is attached to w3wp.exe, the app runs fine and breakpoints are reached. This is in Windows 7 64bit. The same app exhibits the same behavior under VS11beta.
Any ideas why I get this error when using the debugger.
I recently noticed the same thing started on a machine that previously worked just fine. The only change that occurred was the installation of Visual Studio 2011 Ultimate Beta 1. The problem has unfortunately persisted after the uninstall of 2011.
More specifically, it's happening with projects that were opened with the beta.
I was experiencing this problem and deleted my [projectname].suo file. This file exists in the directory where the .sln file is located.
Once I did this the problem no longer exists.
Be sure to back up this file before you try this, and know that you may have to reset a few things (startup project, etc)
The exception is thrown and handled deep inside the .NET Framework. However, you have enabled the option to break even on properly handled exceptions. (I know, because I did too.) You can safely disable that for EntryPointNotFoundException.
Seems like Microsoft is working on this issue
https://connect.microsoft.com/VisualStudio/feedback/details/732334/unable-to-find-an-entry-point-named-getcurrentpackageid-in-dll-kernel32-dll

Visual Studio 2010 SP1 is locking and preventing itself from building the project target assembly

I have a project, which contains various classes and user controls. Every once in a while, often on the second build attempt, Visual studio locks the project's target assembly and the build fails with the following error:
Unable to copy file "obj\x86\Debug\MyProject.dll" to "bin\x86\Debug\MyProject.dll". The process cannot access the file 'bin\x86\Debug\MyProject.dll' because it is being used by another process.
This same issue was reported here: VisualStudio2010 Debugging - The process cannot access the file ... because it is being used by another process. I tried a few of the presented answers, but none of them resolved the matter for me.
Any suggestions?
I read somewhere it's a known issue and they're working on a hotfix - knowing Microsoft it should come out about the time Windows 9 does.
The current only real fix is to uninstall SP1, but since I can't be bothered doing that I just delete all the project files in the Debug folder, but you have to do this every time it throws the error. You can't use a program or batch file to do this since for some reason it completely locks the file and you have to wait ~5mins for the system to unlock and delete it.

Resources