"Access to the path 'C:\Program Files (x86)\Microsoft\Visual Studio\2019\Community\Common7\IDE\Logs' denied" in XAML editor - wpf

I get this strange error from Visual Studio 2019 in the XAML editor, but the project compiles, runs and the assignment is actually working:
I get this error in all UserControls containing this expression. In my MainWindow the same logic causes no Problems. root is just the root namespace which is identical to local on the MainWindow. The settings object in App.xaml.cs looks like this:
public static readonly ISettings Settings;
ISettings is a simple interface for the ConfigurationBuilder of Config.Net.
using Config.Net;
using System;
namespace MyApp.Properties
{
public interface ISettings
{
[Option(Alias = "skin")]
string Skin { get; }
[Option(Alias = "cryptoID")]
string CryptoID { get; }
// ...
}
}
Cleaning, rebuilding, restarting, nothing helps to get rid of the message. I keep ignoring it, but I wish to get rid of it, please.

If your program runs correctly and Visual Studio displays the wavy line warning by mistake, you could try do the following settings to not display the warning wavy line.
Uncheck Display Error Curve :
Tools> Options> Text Editor> General >Display Error Curve
You can also reset the settings.
Tools→Import and Export Settings...→Reset all settings.

Well, the message basically explains what's wrong, so I went ahead and created the folder C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Logs and gave everyone full permission in the ACL security settings in the property window of the folder. Now Visual Studio stops complaining, although no files are created in the folder anyways.
I don't know why this has to be, but the message is gone eventually.

Related

WPF main window not showing for Debug build

I'm working on a C# project with WPF in Visual Studio. My application was building and running perfectly yesterday. As far as I know, I haven't made any changes to the build process.
Today, when I try to run a Debug build, it builds and deploys correctly, and a process starts, but the application startup window never displays (not even in the Windows Taskbar). I tried to attach the Visual Studio Debugger to the process as recommended in this (external) link, but the process is grayed out in the Visual Studio > Debug > Attach to Process... popup. It does not display even if I browse to the Debug folder and double-click the *.exe file.
The unusual thing about this is that if I run in Release rather than Debug, everything works fine. I've checked the Project > Properties > Debug configurations; Debug and Release are identical (I just used the defaults when I created the project). Other projects also work fine in both Debug and Release build. I tried comparing the *.csproj and *.sln files, but I couldn't find any significant differences.
I've tried searching for this, but it's really difficult to find anything useful. This question is unrelated, since the window does not even appear in the taskbar in my case. If I try to include the word "debug," I get a flood of questions about redirecting output to the console, which is not my problem.
I'm not sure what code/configurations are relevant to this question, so please let me know if you need more info about the setup.
Edit 1:
I tried putting a break in the InitializeComponent() method in the auto-generated part of my App class:
public partial class App : System.Windows.Application {
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
#line 5 "..\..\App.xaml"
this.StartupUri = new System.Uri("Views\\MainWindow.xaml", System.UriKind.Relative);
#line default
#line hidden
System.Uri resourceLocater = new System.Uri("/MyProject;component/app.xaml", System.UriKind.Relative);
#line 1 "..\..\App.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public static void Main() {
MyProject.App app = new MyProject.App();
app.InitializeComponent();
app.Run();
}
}
This will break for either Debug or Release if the code is between if(_contentLoaded) { and _contentLoaded = true; but everywhere else in the method, I get "The breakpoint will not currently be hit. No executable code of the debugger's target code type is associated with this line." I get the same message if I try to put a breakpoint anywhere in the Main() method.
Even though Debug breaks at the certain interval mentioned above, it still does not display if I continue.
Edit 2:
Things are starting to get weird. Since the project is backed up in Git, I rolled all the way back to the first commit and to several others along the way. I still couldn't get anything to display for Debug, but Release still worked fine. I even tried deleting the local repo and recloning it, but no success. The stranger part about this is that everything runs fine from the backup folder. Why does the folder name make a difference?
I never found out what caused the issue to occur in the first place, but I was eventually able to come up with two workable solutions.
As described in the edit: Copying the solution directory to another directory and running it from there works for some reason.
For some reason, running Debug|Any CPU didn't work, but running either Debug|x86 or Debug|x64 did.
It's unlikely that someone else will run into my exact situation, but I'm leaving my solutions here for posterity. Maybe someone else can benefit from this.

Designer shows error Could not load file or assembly CefSharp.Core

The designer complains that
Could not load file or assembly 'CefSharp.Core, Version=83.4.20.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138' or one of its dependencies. The system cannot find the file specified.
however it is working fine with a normal execution. Only the designer fails to create an overview of my window.
This happened because I was doing some CefSharp initialization inside my window's constructor.
Wrong
public Browser()
{
InitializeComponent();
InitCefSharp(); // The designer chokes on this, because the overview of the browser is done in a special exotic environment.
}
Right
public Browser()
{
InitializeComponent();
if (!DesignerProperties.GetIsInDesignMode(this)) {
InitCefSharp();
}
}
I hope it helps some with the same problem.

WPF MessageBox in App.xaml.cs stops MainWindow initialisation so app never appears but is (apparently) running correctly

There's no error message and no indication why it is not displaying the window. The app initialises App.xaml.cs: App() {} and I can step through the App.xaml file. It gets the startup uri and then... silence. No output in the Output window and no unhandled exception and no window, I can't find where to put a breakpoint to debug as it isn't hitting the start of MainWindow.xaml.cs.
Really confused.
This was working 20m ago.
In that time all I did was add Windows.Office.Interop.Outlook reference. I removed the reference and rebuilt but still the same. Would that cause this problem? Has anyone seen this before? Google isn't helping!
EDIT :
App.xaml.cs:
public App()
{
using (var dbContext = new DBEntities())
{
if (!db.Exists())
{
try
{
db.Database.Create();
MessageBox.Show("Database created"); // this is the problem!!
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
I've added App.xaml.cs, I found that the problem was using a MessageBox to give info (this is still in development!). I'd been meaning to get rid of it and eventually did and my problem went away. This meant I could find relevent Goolge results:
MSDN query and answer for exactly my problem
I will be adding an 'loading window' in between app load and main window load eventually in which I will be able to feedback information using Bindings etc.
Fixed error by removing the MessageBox.Show(..) call. The selected answer from the MSDN URL given in the question states:
"I performed a test based on your description, the applicationi stop at the method : USER32!GetMessageW+0x33, calling USER32!NtUserGetMessage"
I assume this is what was occurring in my case, although I didn't test it.
What happens if you create a new window and set that as the StartupUri?
You also might want to create a new project and make sure that the namespaces referenced in the App.xaml in your existing app haven't somehow been inadvertently edited.

Why did my Visual Studio 10 stop using App.Config for my SQL connection string?

I have a working database application using WPF and SQL Server 2008 R2, which for two years has been getting its SQL Server connection string from the App.Config file. A few days ago on one dev machine, it started ignoring the App.Config file's connectionString, and is now using a string from somewhere else (looks like either settings.settings, or the DBML file).
Why might this be happening, and how can I get it to stop doing that?
The app.config starts out like this:
<configuration>
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
</configSections>
<connectionStrings>
<add name="DronzApp.Properties.Settings.DronzAppConnectionString"
connectionString="Server=dronz.db.123.dronzdbserver.com;Database=dronzdb;User ID=dronz;Password=secretsauce;"
providerName="System.Data.SqlClient" />
</connectionStrings>
Edit: Thanks for the suggestions from both of you for more info and where to look. I don't know where a WPF App gets the information that it ought to look in App.Config, or anyplace else, but until I learn that, here are some more pieces:
One of the first things my program does is test the database (which now fails). Right before it does that, it calls the auto-generated function InitializeComponent(), whose auto-generated code is:
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/DronzApp;component/ui/startwindow.xaml", System.UriKind.Relative);
#line 1 "..\..\..\UI\StartWindow.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
My start window constructor calls InitializeComponent(); and then tests the database with the line:
int hmm = App.db.Dronz_FooTable.Count();
where App.db is a data context defined in the app.xaml.cs file as:
public static DronzDataDataContext db = new DronzDataDataContext();
where DronzDataDataContext is defined in auto-generated code by LINQ-to-SQL such as:
public partial class DronzDataDataContext : System.Data.Linq.DataContext
...
public DronzDataDataContext() :
base(global::DronzApp.Properties.Settings.Default.DronzConnectionString, mappingSource)
{
OnCreated();
}
Which used to heed the app.config file, and now doesn't. When I catch the DB exception (which is about a DB version problem because it is trying to use the wrong SQL server) and look at the connection string, it is asking the wrong SQL Server for a file instead of the correct connection string. The connection string it is using seems to match either the DBML file that Linq-to=SQL created when the database schema was imported, or a string in settings.settings (which is a file I don't really understand where it came from or what I'm supposed to do or not do with it).
Ok, I seem to have found and fixed the problem, but I don't know what caused it, exactly.
What references the Config file is actually in the .proj file, and somehow it changed to add a reference to app.config at the project root instead of in an App subfolder. From reading other discussion of app.config, I think VS2010 did this automatically perhaps when I was looking at the Project settings in the GUI. Deleting that line of XML manually from the .proj file allowed it to find and use the previous version which points to where the app.config file actually is. Since I didn't have an app.config file in the project root where the new first line was edited to say it was in the .proj file, it seems to have fallen to looking at settings.settings, where it found the connectionString value where the file was when I imported the database file using Linq to SQL.

Can't get rid of a deleted Settings reference in DataSet.Designer.vb

I had a connection string to a MS Access DB file, Foo.accdb, defined and used in my project. It was defined as a connection string Setting in the Settings section of my project properties. The program referenced the connection string setting and everything worked fine.
Then I decided to replace Foo.accdb with two different DB files, A.accdb and B.accdb each of which would be used under different circumstances. I added connection strings for them in Settings and removed the Setting definition for Foo.accdb connection string.
The name of my application is Foo and the name of the Foo.accdb connection string was FooConnectionString.
But now when I build the program both in debugger and for release I get the following error message:
'FooConnectionString' is not a member of 'Foo.My.MySettings'.
The offending reference, in file FooDataSet.Designer.vb, is:
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Private Sub InitConnection()
Me._connection = New Global.System.Data.OleDb.OleDbConnection
Me._connection.ConnectionString = Global.Foo.My.MySettings.Default.FooConnectionString
End Sub
What is going on here? FooConnectionString is not in any other file in the project directory nor in the My Project subdir. I completely got rid of it in my code and in my project properties yet it persists in FooDataSet.Designer.vb (whatever that is).
While researching this on the web I saw a recommendation to select the FooDataSet.xsd file, right click it and execute the "Run Custom Tool" option. I did this and it appears to rebuild FooDataSet.Designer.vb (the time stamp changes) but the problem persists.
I also tried removing the offending reference by manually editing FooDataSet.Designer.vb but that gave me some other error message.
Why is this old reference staying around and what can I do about it?
This is a standalone app. I'm using VS2008 Standard Ed., VB.Net 3.5
Thanks.
Open the FooDataSet XSD file in a text editor. Right click on dataset in the solution explorer and select "Open With..." and the select XML (text) Editor or open it outside the solution.
Look for the <Connections> tag near the top of the file. Remove the line that looks like this
<Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="FooConnectionString" ConnectionStringObject="" IsAppSettingsProperty="true" Modifier="Assembly" Name="FooConnectionString(Settings)" ...

Resources