I have been trying to run the first skeleton program listed here:
https://sites.google.com/site/augmentedrealitytestingsite/download
I am using VS2010 express under Windows 7 64bit.
When I tried to build and run, it first threw:
"An attempt was made to load a program with an incorrect format"
Followed shortly by a System.BadImageFormatException due to calling a PInvoke method from the referenced ARTKPManagedWrapper.DLL.
I recompiled the reference on my PC but the problem persisted. I also tried to set the target platform to x86 (it is currently set on Any CPU) but there was no option other than Any CPU.
Does anyone have any idea what else could be going wrong here?
You have to create the option if it isn't there. I was able to get it to work by going into Build --> Configuration Mananger going into the Platform Column and creating an new x86 configuration.
If configuration manager is not visible to you. You will want to look at this Blog
From Blog:
First, select Tools|Options to bring up the Options dialog.
Make sure that "Show all Settings" in the bottom left-hand corner is set.
Select the Projects and Solutions page and set "Show Advanced build configurations."
and from the Comments
You've just got to ensure that Tools -> Settings -> Expert Settings is selected as well.
In IIS on the app pool for the website under the advanced settings change the following setting
Enable 32 bit applications to true.
Related
I have a predominantly managed c# .net 4.6 app that is trying to call into a c++ dll (that is also built as part of the solution), Visual Studio 2017.
I get this exception:
"System.IO.FileNotFoundException: 'Could not load file or assembly 'XXX.dll' or one of its dependencies. The specified module could not be found.'"
There doesn't appear to be any more information. The dll is in our binaries directory with all our other dlls that load fine, and the exe that is being run in the debugging session (The start up project).
I've checked the solution configuration manager, its building the dll as x64 in our Debug|Any CPU config, which makes sense.
No one else in the office has this issue, and I didn't have this issue on my old computer (I'm getting now trying to set up my new dev computer, which is the exact same specs as the old one) Windows 10.
I have the WindowsSDK 8.1 and 10 installed, and the vs c++ redistributes.
Any Ideas? Or atleast, and idea how I can get more info about whats actually going wrong? (This exception is frustratingly vague).
You’d want to use Fuslogvw.exe, the assembly binding log viewer. It can be started by launching the Developer Command Prompt for VS. The first thing is to enable logging, and the simplest way is to run as administrator (as a comment to an answer here correctly points out); you can alternatively set the ForceLog regkey specified here if running as a regular user account.
There's also a small video I did a while back to test how this works. You can find this in this article. Just scroll to the bottom, it's within the 2nd question starting from the end.
If that doesn't work, run Process Monitor and set a filter for your specific .dll and see what the CLR does in detail when searching for it.
I have been assigned to work on a Windows Service project. I installed it in my machine using installer class (ProjectInstaller.cs). I want to debug the source code and sometimes need to make changes while it is in debug mode. I attached the process via Debug menu to debug the project which works fine but it throw an error while I am trying to edit or continue the source code:
Managed Compatibility Mode does not support Edit and Continue
I googled and tried tons of solutions but none of them worked for me, couple of them are as below:
Unchecked the Use Managed Compatibility Mode from Tools -> Options
Unchecked Managed Compatibility Mode from Debug -> Attach to Process
-> Attached To -> Select...
Checked the Managed (v4.6, V4.5, V4.0) from Debug -> Attach to
Process -> Attached To -> Select...
Played with Platform target in Project Build.
Added {351668CC-8477-4fbf-BFE3-5F1006E4DB1F} field in my .csproj file
The error message varies depending on different solutions I implemented.
Below is the link I last time tried:
https://blogs.msdn.microsoft.com/visualstudioalm/2013/10/16/switching-to-managed-compatibility-mode-in-visual-studio-2013/
I am guessing: the last one didn't work because I do not have an exe project for my service instead I have implemented ProjectInstaller.cs Class and manually installed it through command prompt.
Any suggestion/recommendation are welcomed.
Edit and Continue requires many factors which are not obvious to users. Your case is simply not supported (mostly for attaching cases).
See Supported Code Changes (C#) in MSDN. In particular:
Edit and Continue is not available in the following debugging scenarios: [...]
Debugging an application that has Attach to instead of running the application by choosing Start from the Debug menu.
Unckeck Use Managed Compatibility Mode, It working for me! and you must Enable Edit and Continue in Debuging General
Attaching my process for each debug was a headache for me.
Just want to share a link that saved a lot of my time by writing a simple method and calling it in Main() method inside Program.cs.
This also gives me flexibility to edit and continue my code as simple as WinForm / Web Form. LOVE IT.
https://coding.abel.nu/2012/05/debugging-a-windows-service-project/
I reset the VISUAL STUDIO settings and the problem is resolved
hope it helps to Reset visual studio setting
When I click "Publish" in my project properties, what files are actually getting published? I spent some time yesterday searching MSDN, but didn't find a clear answer.
I assumed (perhaps incorrectly) that it was publishing the latest version in source control, so I always made sure I had my changes checked in before clicking "Publish". But now I'm highly suspicious, based on a bug that was reported, that it has been publishing the Debug configuration on my laptop. I have code that should only execute in debug mode (#if DEBUG...), and it seems to be executing that code in production.
This is my first WinForms application and first time using ClickOnce deployment. Any guidance would be greatly appreciated.
What code is getting published? Latest in source control, most
recent build on build server or from local machine?
What settings do I need to set (and where are they) to ensure that my
application is published using the Release configuration?
TIA
UPDATE(S):
Here is what I see on the Publish tab
Does the Build tab come into play at all?
The Configuration setting on the Build tab is what matters when Publishing, correct? Not the selection in the toolbar?
For ASP.NET applications, when you go to publish, there will be a configuration option under settings:
The code you have locally is what gets compiled and published through Click Once. For non ASP.NET applications, the build configuration selected in visual studio is what ultimately gets published.
For this specific case, you have "Define DEBUG constant checked". That will cause the code marked as #DEBUG to be executed. It doesn't matter what the build configuration is if that is checked.
I tried on some settings on my project.
1) Select Configuration Manager by right clicking on your Solution.
2) When i clicked publish, here is what i get in output window
3) If you want to control what files (dependencies) are included as part of deployment, this can be controlled from Application Files button on the publish tab of project properties.
Here is an image.
Hope that helps.
Visual Studio 2010 kills (there is no other word) data in one of the arguments of the function in the unsafe block.
What could cause this error? The following message shows by the debugger.
Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away.
Go to Project Properties and under Build Make sure that the "Optimize Code" checkbox is unchecked.
Also, set the "Debug Info" dropdown to "Full" in the Advanced Options (Under Build tab).
Also
In VS 2015 Community Edition
go to
Debug->Options or Tools->Options
and check
Debugging->General->Suppress JIT optimization on module load (Managed only)
If you compile with optimizations enabled, then many variables will be removed; for example:
SomeType value = GetValue();
DoSomething(value);
here the local variable value would typically get removed, keeping the value on the stack instead - a bit like as if you had written:
DoSomething(GetValue());
Also, if a return value isn't used at all, then it will be dropped via "pop" (rather than stored in a local via "stloc", and again; the local will not exist).
Because of this, in such a build the debugger can't get the current value of value because it doesn't exist - it only exists for the brief instant between GetValue() and DoSomething(...).
So; if you want to debug... don't use a release build! or at least, disable optimizations while you debug.
In visual Studio 2017
goto Debug->Option then check Debugging->general->
and check this option
I just ran into this and I was running under Release build configuration instead of Debug build configuration. Once I switched back to Debug my variable showed in the watch again.
For web applications there is another issue which is important and it is selecting correct configuration during application publish process.
You may build your app in debug mode, but it might happen you publish it in release mode which omptimzes code by default but IDE may mislead you since it shows debug mode while published code is in release mode.
You can see details in below snapshot:
I have faced the same issue and the solution for me is change Solution Configuration from Release to Debug. Hope it helps
When I was faced with the same problem I just had to clean my solution before rebuilding. That took care of it for me.
Regarding the problem with "Optimize code" property being UNCHECKED yet the code still compiling as optimized: What finally helped me after trying everything was checking the "Enable unmanaged code debugging" checkbox on the same settings page (Project properties - Debug). It doesn't directly relate to the code optimization, but with this enabled, VS no longer optimizes my library and I can debug.
In my case, I was working on a web api project and although the project was set correctly to full debug, I was still seeing this error every time I attached to the IIS process I was trying to debug. Then I realized the publish profile was set to use the Release configuration. So one more place to check is your publish profile if you're using the 'Publish' feature of your dotnet web api project.
I found that I had the same problem when I was running a project and debugging by attaching to an IIS process. I also was running in Debug mode with optimizations turned off. While I thought the code compiled fine, when I detached and tried to compile, one of the references was not found. This was due to another developer here that made modifications and changed the location of the reference. The reference did not show up with the alert symbol, so I thought everything was fine until I did the compilation. Once fixing the reference and running again it worked.
As an additional answer for those experiencing this issue when debugging an Azure websites' web app:
When deploying from GitHub, for example, the code is compiled in Azure server optimized by default.
I tell the server to compile in a debuggable way by setting SCM_BUILD_ARGS to /p:Configuration=Debug
but there are more options. See this:
http://azure.microsoft.com/blog/2014/05/08/introduction-to-remote-debugging-on-azure-web-sites-part-3-multi-instance-environment-and-git/
In Visual Studio 2017 or 2015:
Go to the Solution right click on solution then select Properties-> select all the Configuration-> Debug then click OK.
After that Rebuild and Run,this solution worked for me.
Had the same issue before with a WPF application and all the solutions here did NOT solve the issue. The problem was that the Module was already optimized so the previous solutions DO NOT WORKS (or are not enough to solve the issue):
"Optimize Code" checkbox un-Checked
"Suppress JIT optimization on module load" checked
Solution configuration on DEBUG
The module is still loaded Optimized. See following screenshot:
To SOLVE this issue you have to delete the optimized module. To find the optimized module path you can use a tool like Process Hacker.
Double click your program in the "Process panel" then in the new window open the tab ".NET Assemblies". Then in the column "Native image path" you find all Optimized modules paths. Locate the one you want to de-optimize and delete the folder (see screenshot below):
(I blurred my company name for obvious reasons)
Restart your application (with check box in step 1 correctly checked) and it should works.
Note: The file may be locked as it was opened by another process, try closing Visual Studio. If the file is still locked you can use a program like Lock Hunter
Check to see if you have a Debuggable attribute in your AssemblyInfo file. If there is, remove it and rebuild your solution to see if the local variables become available.
My debuggable attribute was set to: DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints which according to this MSDN article tells the JIT compiler to use optimizations. I removed this line from my AssemblyInfo.cs file and the local variables were available.
In Visual Studio 2012:
Go to the project properties -> Debug -> Uncheck "Enable the Visual Studio hosting process"
I had the same issue. Tried all the above and found I also had to delete everything inside {PROJECT_ROOT}\bin\Release\netcoreapp2.2 and {PROJECT_ROOT}\obj\Release\netcoreapp2.2 for my project. Its definitely releated to publishing because although I use Deployment tools / bitbucket on my Azure Web App, I did try the Build >> Publish >> Publish to Azure because I wanted to inspect which files were actually deployed.
for some reason this no longer works. I ugraded the winforms solution from VS2008 to VS2010 and on new machine also Windows 7 64bit but id does not allow edit and continue
I haver set the options to enable it and to compile against 86 cpu
any ideas?
also Windows 7 64bit
Edit+Continue only works for 32-bit code. Easy fix, and the default now for VS2010 projects: Project + Properties, Build tab, Platform target = x86. You can of course leave that setting for your Release configuration at Any CPU.
try this link. quoting from it
Edit and Continue is enabled under Tools>Options>Debugging>Edit and Continue
My solution platform is set to x86
My solution configuration is set to Debug
All my projects are building for Debug and x86
For all projects under Projects>Properties>Build the Optimize code is unchecked
tools->options->unselect intellitrace events and call information
I know it's a old question... but I not found a similar answer on another question.
I was having this issue for months. I found today a solution on my PC (win7 x64):
I run VS2010 with administrator privileges (uac enabled, popup appears and I accept everytime that I run vs 2010) this is because I need a 3rd party addon to work.
It appears that running vs 2010 with admin privileges make it run on another account or something else...
I checked one setting on vs2010 that allowed me to edit and continue now again :)
this option is under:
Tools/Options/Debugging -> Edit and Continue -> check "Enable while remote debugging or debugging and aplication running under another user account"
note: vs2010 will show a warning (security related...).. I not sure how dangerous it is... but works
I hope that this solution can help someone.
In my situation, someone added a Reference to the Project's output into the Reference list: in Solution Explorer look under [ProjectName]\References for [ProjectName*] and remove it. If the project is relying on code from a copy of itself, you can't 'Edit and Continue'.
In the warning list you'll see conflicts with imported type messages if this was the cause of the problem.
I've seen this as well. It seems that some stuff of the expressions and lambdas cause this. ;(
I have the same problem and found this info from the MSDN page "How to: Use Edit and Continue (C#)" :
Note
Edit and Continue is not supported when debugging 64-bit code, the Compact Framework, optimized code, mixed native/managed code, or SQL Server common language runtime (CLR) integration code. If you try to apply code changes in one of these scenarios, the debugger puts up a dialog box explaining that Edit and Continue is not supported.
I think the mix of native/managed code is the problem for me (my project indeed mixes them).