I'm trying to use a local secrets.xml file but an error tells me that it can't be found.
I right-clicked on the project and selected 'Manage User Secrets, which created the GUID-named folder and file for me. That same GUID appears in the userSecretsId attribute as below...
<configBuilders>
<builders>
<add name="Secrets" optional="false" userSecretsId="[a GUID]" type="..." />
</builders>
</configBuilders>
But at runtime an exception shows that the file cannot be found.
I then switched to using userSecretsFile and pasted a copy of the file to C:\tmp\secrets.xml. This worked.
So I then pasted the path of the auto-generated secrets.xml - i.e....
%APPDATA%\Microsoft\UserSecrets\<userSecretsId>\secrets.xml
...into the userSecretsFile attribute...
<add name="Secrets" optional="false" userSecretsFile="C:\Users\[my username]\AppData\Roaming\Microsoft\UserSecrets\946bd95c-42a4-45da-aad0-a7874c97fd64\secrets.xml" type="..." />
...and still an exception is thrown saying that the file can't be found.
I'm running Visual Studio 2019 with administrator privileges. Why does it appear to be prevented from accessing the file?
I just changed my laptop. I am moving my old project done in MVC 4 and was done in Visual Studio 2012. My current Visual Studio in my new laptop is 2017 version.
There is a problem when I want to debug my MVC application. This error comes out after I run the debug:
HTTP Error 403.14 - Forbidden The Web server is configured to not list
the contents of this directory.
Most likely causes: A default document is not configured for the
requested URL, and directory browsing is not enabled on the server.
I never set my application to be listed in directory browser. My application is an MVC application which will run global.asax and redirect to my home page.
How can I fix this?
enable directory browsing.
keep this into your web config file then rename the add value="pagename.aspx"
<system.webServer>
<defaultDocument>
<files>
<add value="yourpage.aspx" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />
</system.webServer>
or
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
You can also enable directory browsing from IIS
Open a command prompt, and then go to the IIS Express folder on your computer. For example, go to the following folder in a command prompt: C:\Program Files\IIS Express
Type the following command, and then press Enter:
appcmd set config /section:system.webServer/directoryBrowse /enabled:true
Got the same error, but MVC5 on VS2017. Eventually found I got the error because i had marked Application_Start() in Global.asax as a static. I did that because i made the mistake of following this Code Analysis recommendation:
This is a potential duplicate of
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents
Different context since you are trying to debug in IIS express and you are not hosting the application in IIS, however the error is the same and the answers is worth checking out. Could set you on the right path.
Would have commented but don't have enough rep yet.
Make sure you have defined your default application inside the hosts file in your new laptop.
This is a cause for many headache.
See it under:
C:/Windows/System32/Drivers/etc/hosts
I've been trying to wrap WPF app inside a Windows Universal App, using Desktop Bridge.
In order to make the app's taskbar icon unplated, with transparent background, I followed the instructions that can be found in various blogs and MSDN articles/forums, such as this one.
The first commands I've been executing are these two:
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64\makepri.exe" createconfig /o /cf priconfig.xml /dq en-US
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64\makepri.exe" new /o /pr . /cf priconfig.xml
These commands were executed in the WPF app's output folder, where I also put an AppxManifest.xml file, along with the files and folders referenced by it (such as the Executable file and the Assets' images in various scales and resolutions).
From this point, I got two different weird errors:
First, If the AppManifest.xml file contains the following section:
<Extensions>
<desktop2:Extension Category="windows.firewallRules">
<desktop2:FirewallRules Executable="app\MyWpfApp.exe">
<desktop2:Rule Direction="in" IPProtocol="TCP" Profile="all" />
<desktop2:Rule Direction="in" IPProtocol="UDP" Profile="all" />
</desktop2:FirewallRules>
</desktop2:Extension>
</Extensions>
then the second makepri command will result in the following error message:
onecoreuap\base\mrt\tools\indexertool\src\tool\parametermanager.cpp(:908): error PRI175: 0x80080204 -
onecoreuap\base\mrt\tools\indexertool\src\tool\parametermanager.cpp(:318): error PRI175: 0x80080204 -
Microsoft (R) MakePRI Tool
Copyright (C) 2013 Microsoft. All rights reserved.
error PRI191: 0x80080204 - Appx manifest not found or is invalid. Please ensure well-formed manifest file is present. Or specify an index name with /in switch.
Then if I remove that FirewallRules section, everything seems to run fine - at least on my machine.
Second, It doesn't always run as expected:
when I try to run exactly the same files (with the fixed version of AppxManifest.xml) and same commands on a different machine, I get the same error that I used to get in the first machine (from before removing the FirewallRules section).
Any idea what could be causing these problems? What possible differences between the build machines could cause the second problem? What should I look for?
The first problem was solved by removing the IgnorableNamespaces property from the Package xml-element (at the root level of AppxManifest.xml).
--
As for the second problem, after contacting Microsoft's support team about this issue, this seems to be a bug in the makepri tool running on older systems:
Apparently, when running on Windows Server 2012 R2 (and perhaps other version as well), the makepri tool command has to supplied with another "optional" parameter that states the app's name:
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x64\makepri" new /o /pr . /cf priconfig.xml /mn AppxManifest.xml /of resources.pri /in "MyAppName"
The important part is the /in "MyAppName" argument at the end of the line, though the other arguments might be crucial as well. Also, "MyAppName" has to be the same as defined in the AppxManifest.xml file, in that part:
<Applications>
<Application Id="MyAppName" ...>
...
Another step that might have been relevant to solve this issue, was to make sure that the file-mappings file, used later for the makeappx command, has the correct definition for ResourceId - as explained in this article.
Following instructions here I have:
var connectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");
But connectionString is null, here is my app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<add name="StorageConnectionString"
connectionString="DefaultEndpointsProtocol=https;AccountName=storage;AccountKey=key" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.0.0" newVersion="5.2.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Had the same problem. Instead of using a connection string, use the configuration->appSettings->add key like this...
<configuration>
<appSettings>
<add key="StorageConnectionString" value="[ConnectionStringHere]" />
</appSettings>
</configuration>
As per documentation in MSDN http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.cloudconfigurationmanager.aspx
Only configuration settings within the appSettings tag can be read by CloudConfigurationManager. If your configuration settings are within a different tag, calling GetSetting will return Null.
Well this works, even if the comment doesn't fit, because I do have a ref to CloudConfigManager:
If you are creating an application with no reference to Microsoft.WindowsAzure.CloudConfigurationManager, and your connection string is located in the web.config or app.config as show above, then you can use ConfigurationManager to retrieve the connection string. You will need to add a reference to System.Configuration.dll to your project and add another namespace declaration for it:
using System.Configuration;
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
I had the same problem. I had updated the project to use Azure SDK 2.0. I updated NuGet packages for my web and worker roles, but the Azure project in Visual Studio was still on the old version.
To fix this, Right-Click on your Azure project and select Properties. Under the Application tab, you'll see a button to Update your Azure SDK.
Make sure all your references are in synch. There's the 2012-06 library and 2012-10 Set them to Copy Local = true and verify SDK version. I dealt with the exact same thing, drove me nuts.
This happened to me when I upgraded the Azure SDK to version 2.2.
To fix it I changed the packages.config to use a newer version of the Azure ConfigurationManager.
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.1.0" targetFramework="net45" />
Based on my understanding, I'd like to point out that CloudConfigurationManager.GetSetting will look into web.config if you're running out of a cloud service. It will look into cscfg if you're inside a cloud service.
Please refer this
link.
Following this tutorial:
You can get configuration settings like this:
RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString")
I got this after upgrading Azure SDK from 2.0 to 2.2. I was able to fix by:
Right-Clicking Azure project and selecting Properties. Update Azure SDK as per the Application tab. (Thanks to rattrick's answer).
Right click to Manage NuGet Packages. On the left click Updates and update WindowsAzure.ConfigurationManager.
I had the same problem (two times).
Even after restarting Visual Studio and after restarting the Azure emulator the CloudConfigurationManager.GetSetting("SettingName") returns null.
I was sure that it has worked before and I had the latest SDK.
So the solutions was restarting my PC and after that CloudConfigurationManager.GetSetting("SettingName") returns the right value.
I got the same issue this am after revisiting my Azure solution (Web + Worker role) to update it for Azure 2.5. Reviewing the help for CloudConfigurationManager.GetSetting, if its running under a cloud platform (Azure) it reads from the ServiceConfiguration.csfg, if running as a .net web app, reads from app or web.config.
So my fix was to simply change the start up project back to the Azure cloud project, not the Web project.
I was getting null because it was hosted in the wrong platform and reading from the .config files with no settings.
(Doh!)
It is an old thread but I wanted to share my solution if issue is not resolved by above mentioned methods then make sure that Azure Storage Emulator is running when you run the application; at least for me this happened. For me I had to create a class to handle emulator issue as mentioned here...
http://blog.simontimms.com/2013/08/28/configuration-settings-in-an-azure-worker-role/
class ConfigurationProvider
{
private static string GetStorageConnectionString(string name)
{
try
{
return RoleEnvironment.GetConfigurationSettingValue(name);
}
catch (SEHException)
{
return System.Configuration.ConfigurationManager.ConnectionStrings[name].ConnectionString;
}
}
public static string StorageConnectionString()
{
return GetStorageConnectionString("StorageConnectionString");
}
public static string DefaultConnection()
{
return GetStorageConnectionString("DefaultConnection");
}
}
I had quite similar problems. I updated from Azure SDK 2.0 to 2.2 - during this process I used the NuGet Manager to update the Microsoft.WindowsAzure.Storage to the latest. The PackageManager automatically took Microsoft.WindowsAzure.Configuration to 1.8.0.0. I was not able to get this running (it was for .Net 2.0!?). After I manually set all References to
Microsoft.WindowsAzure.Storage 2.1.0.0
Microsoft.WindowsAzure.Configuration 2.0.0.0
everything worked.
I think this is because of the way CloudConfigurationManager.GetSetting loads the assembly and calls the funktions (via reflection).
Same here after upgrading Azure SDK from 2.2 to 2.3.:
Right-Click the Azure project select Properties. In the Application tab click "Upgrade..." (Thanks to rattrick's answer).
Then there was one more error to resolve:
Trying to run the Azure Project in the Compute Emulator threw an exception:
System.Configuration.ConfigurationErrorsException was unhandled
Message: An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in Microsoft.WindowsAzure.ServiceRuntime.dll
Additional information: konnte nicht erstellt werden.
In the "Error List" Window of VS2013 there was the following Warning:
Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets 1635
I let VS resolve this warning and everything worked fine.
This worked for me...
using System.Configuration;
...
var connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
I had the same problem. None of the advices worked for me, but the "issue" was straightforward. One simple has to understand how this class works.
It does not go into your app.config / web.config or wherever you store your application settings. CloudConfigurationManager works with ServiceConfiguration.*.cscfg and ServiceConfiguration.csdef. The .csdef must contain a definition of the setting, but not its value under the ConfigurationSettings section. The settings themselves sit in .cscfg files (under the same section but including the value; I suppose the reason for the double definition is to make sure both the cloud and the local configurations have the same settings).
You can set these either by right-clicking your role in Visual Studio and selecting Properties -> Settings (in case of StorageConnectionString, simply pick "Your subscription", if your storage account is connected to the cloud service), or by editing them manually. If you mess up the settings, you'll get an exclamation mark icon.
Simple as that.
Was getting a null value with when passing a literal string as well after installing Azure SDK 2.6 (was working before).
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureStorage"].ConnectionString);
Replaced the literal string and it worked fine.
string connectionStr = "AzureStorage";
var connectionstring = ConfigurationManager.ConnectionStrings[connectionStr].ConnectionString;
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionstring);
I am using IIS 6 on 2003. I have created a HTTP handler dll that inherits from IHttpAsyncHandler. The dll builds into the inetpub\www8080root\common\bin directory. It is meant to intercept all requests.
The web site is set to monitor port 8080. I have created a common folder in the www8080root directory and have created a virtual directory in II6 to point to it.
I created a web.config file in the common directory
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" defaultLanguage="c#" />
<httpHandlers>
<add verb="*" path="*"
type="x2Handler.x2Handler, x2Handler" />
</httpHandlers>
</system.web>
</configuration>
When I access http://localhost:8080/common/index.html the HTTP handler causes a crash of w3wp.exe, when I look in the event logs I can see the error within the handler that caused the crash. When I set a breakpoint within VS 2005 the code it doesn't get hit.
In order to debug I need to somehow attach to the process when it is running under IIS but as soon as it processes a request, it crashes.
How do I debug a HTTP Handler dll under IIS? I can't see a aspnet_wp.exe process to attach to as described here: C#, Debugging an HTTPHandler
EDIT:
By adding Debugger.Break() I now receive the message "w3wp.exe has triggered a breakpoint" and it allows me to select a debug environment, but it loads without symbols
No symbols are loaded for any call stack frame. The source code cannot be displayed.
I set Tools->Options->Debugging->Enable Just My Code
I set the path to the common/bin location to load symbols from. Any manually set breakpoints still display:
The breakpoint will not currently be hit. No symbols have been loaded for this document.
EDIT:
When it loads it appears to be looking for the symbols of ntdll.pdb. Even if I manually load the symbol file for the httpHandler it makes no difference.
The code is definitely executing though.
Add Debugger.Break() a few lines before the exception occurs. This should give you a popup asking to attach a debugger.
The problem was that .Net had been installed prior to the version IIS. I had noticed the "Edit configuration" button was disabled and found this site http://www.warfiblog.com/edit-configuration-disabled.
Following the instructions:
You will need to go to Start -> Microsoft Visual Studio 2005 -> Visual Studio Tools -> Visual Studio 2005 Command Prompt. On the prompt write down this command:
aspnet_regiis -r
The above command will register dot net with IIS and now the button will also be enabled.
In doing that it fixed the debugging issue!