Not running in a hosted service or the Development Fabric - visual-studio-2010

I have a problem related to the webRole debugging.
Not running in a hosted service or the Development Fabric.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Not running in a hosted service or the Development Fabric.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Not running in a hosted service or the Development Fabric.]
Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.GetDefaultStartupInfoForCurrentRoleInstance() +169
Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener..ctor() +57
[ConfigurationErrorsException: Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.]
System.Web.Security.Roles.Initialize() +2230194
System.Web.Security.RoleManagerModule.OnLeave(Object source, EventArgs eventArgs) +68
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
This is the web.config part concerning Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>

One thing to check: Make sure your cloud project is set as the startup project.

Most of the Azure diagnostics require administrative rights. You may not have started the Windows Azure Compute Emulator as an Administrator and that is the reason why the API calls failed.
The solution – start the Windows Azure Compute Emulator as an Administrator, or let Visual Studio start the emulator (provided Visual Studio is already running with administrative rights).

Related

Lightswitch 2013 app 400 Bad request

I deployed a LightSwitch 2013 web application to my local web server using the publishing tool in Visual Studio. The site works great with no problems. I am able to load records from the external SQL Server.
When I deploy the same published package to our UAT web server there is an error statement where the data records are displayed that reads "Request failed with status code '400' and status text 'Bad Request'." I turned on the Failed Request tracing for the application and found 2 logs. Here are the tracing logs:
Url -> http://uatwebsrvr:80/LSApp/ApplicationData.svc/$metadata
App Pool -> LSAppPoolv4.0
Authentication -> anonymous
User from token -> NT AUTHORITY\IUSR
Activity ID -> {00000000-0000-0000-D000-0080000000EE}
Site -> 1
Process -> 3448
Failure Reason -> STATUS_CODE
Trigger Status -> 400
Final Status -> 400
Time Taken -> 0 msec
The second log is identical to this log with the exception of the service being used.
I compared the IIS configs on the UAT server and my Dev server. The only differences that I could find are some missing assemblies on the UAT server. But I don't really think this is the issue. The missing assemblies are these 3:
*Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35*
The application pools have identical configurations.
One other thing. I created a very basic Lightswitch application to display some database records to test the database connection. I deployed this to the UAT web server and this application works perfectly. This app uses the same database as my real app.
This issue has been resolved. The resolution is to change all the references on the server project to "Copy Local"

IIS Express / VS Config works only for myself, not other users

Using Visual Studio 2010 and IIS Express. The web site site I'm debugging will only accept logins from my domain account. If I connect to the site from a different system logged in as someone else, I'm given a 401 error after the credentials are rejected several times. I don't think this is a firewall issue, as I've disabled all of those I can find. Once IIS Express is running, I can see the ports its bound to are accepting requests:
TCP 0.0.0.0:64611 0.0.0.0:0 LISTENING
TCP [::]:64611 [::]:0 LISTENING
From IISExpress/Config/ApplicationHost.config:
<location path="CAF">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
The application's web.config (relevant section):
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Windows"/>
</system.web>
And in Visual Studio, the project shows "Anonymous Authentication = Disabled" and "Windows Authentication = Enabled".
I start Visual Studio as "Administrator" (shift, click, "Run as Administrator") otherwise the error "Unable to connect to the configured development web server, Failed to register URL http://*:64611/ for site CAF application /. Error description: Access is denied (0x800700005)" occurs. Starting VS as Admin fixes that problem, and the site works normally except it ONLY authenticates me.
I'm kind of stumped here, and I can't really test out some multi-user features unless I can connect as a couple of different users.

RavenDb on Azure Websites - Access Denied

I'm playing around with the new Websites feature on Azure and trying to get an MVC site running with RavenDB in embedded mode. Everything works fine locally but running the deployed site in azure I get this error:
System.Net.NetworkInformation.NetworkInformationException: Access is denied
This happens when I create the db instance in global.asax:
Store = EmbeddableDocumentStore { ConnectionStringName = "RavenDb" };
My connection string is:
<add name="RavenDb" connectionString="DataDir=~\App_Data\Raven" />
Thanks!
When a port is not specified for RavenDb it will go out and attempt to find it's own, it does this by calling IPGlobalProperties.GetActiveTcpListeners().
RavenDb | PortUtil.cs
var activeTcpListeners = IPGlobalProperties
.GetIPGlobalProperties()
.GetActiveTcpListeners();
Calling GetActiveTcpListeners() intern calls the Win32 function GetTcpTable() which attempts to enumerate all of the possible port combinations on the host. For obvious reasons, it would not be a good scenario to allow folks to do port scanning within Windows Azure Web Sites. Which means the GetTcpTable operation fails and when something fails in the world of development we throw an exception.
In this particular case the exception is a NetworkInformationException which is raised do to the security permissions neglecting the call to GetTcpTable. This is why it results in an Access Denied message.
tl;dr
Add a default port to your web.config appsettings section:
<appSettings>
<add key="Raven/Port" value="*"/> <!-- Add real tcp port # -->
<add key="Raven/DataDir" value="~\Data"/>
<add key="Raven/AnonymousAccess" value="Get" />
</appSettings>

"Bin Deploy" Sql CE 3.5 SP2 & Error when it's already installed

I've got an app that uses Sql CE 3.5 SP2. I've included the DLL's that Sql CE requires - there are 7 of them found here (C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5) that I simply add to my deployment package as application files.
I also use the EF to access the DB, so I've added an entry to my app.config file to provide a Data Provider:
<system.data>
<DbProviderFactories>
<add name="Microsoft SQL Server Compact Data Provider"
invariant="System.Data.SqlServerCe.3.5"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
Doing the above works for my deployed apps; however, when I run my app in debug mode from VS2010, any DB calls that run through the EF come up with this error:
The specified store provider cannot be found in the configuration, or is not valid.
If I remove the entry from my app.config it works fine but stops working for deployed apps.
Is there a happy medium? I'm assuming that the cause of the error is because I have a legit copy of Sql CE installed on my development machine and for whatever reason, registering it in my app.config causes it to break, though I don't completely understand why.
Tips? Suggestions?
Thanks in advance.
I should have done a little more searching. I found the problem, it seems I need to remove the provider before adding it. When a real install of Sql CE is present, it registers itself in the machine.config, so adding it to the app.config causes it to be registered twice.
This is what should go in the app.config
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.3.5" />
<add name="Microsoft SQL Server Compact Data Provider"
invariant="System.Data.SqlServerCe.3.5"
description=".NET Framework Data Provider for Microsoft SQL Server Compact"
type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>

Using IIS7 and vs2010 to do remote debugging with MVC2 and Windows Authentication

What I am doing
I am building an MVC2 website with Windows Authentication using Visual Studio 2010. I want to debug the website using IIS7 and access it from a browser in a virtual machine (in order to sign in using different users with different privileges).
Problem
When I try to access my website from my virtual machine, I get the following error:
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
Environment
I have visual Studio 2010 set to debug using IIS and to "Don't open a page. Wait for a request from an external application." I have created www.myWebsite.com in IIS7 on my host machine and have only Windows Authentication enabled.
I have made appropriate entries in the hosts file on both the virtual machine and my host machine so that when I type www.mywebsite.com into the browser on my virtual machine, it targets my website I set up on IIS7.
I tested my IIS7 setup process by using the same settings to set up an html website (with the same web.config security settings) and I could access that from my virtual machine. For this reason I think the problem has something to do with my application. IIS7 is set up to use .net 4.0 and Integrated Pipeline Mode.
Code
Here is my web.config file:
connectionString="metadata=res:///Models.ReportDB.csdl|res:///Models.ReportDB.ssdl|
res://*/Models.ReportDB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=JDOE-
PC;Initial Catalog=ADVENTUREWORKSDB;Integrated Security=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
res:///Models.WDB.ssdl|res:///Models.WDB.msl;provider=System.Data.SqlClient;provider connection
string="Data Source=JDOE-PC;Initial Catalog=WarehouseDB;Integrated
Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
PublicKeyToken=31BF3856AD364E35" />
PublicKeyToken=31BF3856AD364E35" />
PublicKeyToken=31BF3856AD364E35" />
PublicKeyToken=b77a5c561934e089" />
type="System.Web.Security.WindowsTokenRoleProvider"/>
type="System.Web.Security.WindowsTokenRoleProvider"/>
type="System.Web.Security.WindowsTokenRoleProvider" />
I started over and everything has been working fine. I'm curious what the problem is, but with all the settings I was messing with (was doing a lot of experimenting as this was my first MVC project) I probably hosed something.
I don't think I have enough information to really solve the problem, so I will close this question.

Resources