Azure - Debug web application without Azure Emulator - visual-studio-2010

I have a web application which is hosted by ourself.
We plan to host in Azure soon, so I add Azure project.
Now on, whenever I debug, Azure Emulator is loaded. It is very slow to debug in Emulator.
I uncheck Azure project for Debug in Configuration Manager, but it still debug with Azure Emulator.
Is there anyway I can debug (like my old single web application) without Azure Emulator? I can delete Azure project while debugging, and create it again when ready to publish to Azure; however, it is not convenience.
Thanks in advance!

If you set your web role project (not the azure/cloud one) as the startup project you should be able to debug the web (asp.net?) project normally (on development webserver, IIS or IIS express).

To debug your web application without starting the emulator you can simply right click the web project, choose Debug and then Start new instance:
Now, you'll have to watch out for one thing. By default, your web application will have the following in its web.config:
<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>
Now, if you're using Trace and Debug in your application you'll need to comment this line out. If you don't do this, you'll end up having erros when logging using Trace or Debug:
Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

Related

Errors when trying to use StackExchange REDIS in Azure Cloud Service Worker Role

I have a solution hosted in Azure that is using ServiceStack.Redis 2.0.601.
App Services (Web API) and On-Premise windows services are all working as expected but the Cloud service worker roles are throwing binding errors.
Add Binding redirect and enable auto binding redirect in the worker role.
Use ILSpy to verify the versions that are copied by the build have same version as defined in the binding redirect.
Use fuslogvw.exe to catch binding errors but couldn't make it get any data from the Cloud Service Emulator
I'm running the same code with same app configs in other type of projects and all working great
The code is very simple, Create a cloud service with one worker role.
Add StachExchange.Redis nuget version 2.0.601 and try to connect a REDIS instance using the following line:
var connection = ConnectionMultiplexer.Connect(#ConnectionString#);
This is the only line I have in the code inside WorkerRole.OnStart Method.
System.BadImageFormatException: 'Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)'
I was getting similar errors, and realized I needed to add a bunch of additional Nuget packages.
System.Buffers
System.IO.Pipelines
System.Memory

Deploy a Multi-Tenant WebApi with Tenant-Specific Configuration

Is there a way to deploy a single instance multi-tenant aware web api with specific configuration per tenant?
We have an Asp.net Web Api witch identify the tenant by claims inside a JWT but into the web.config are configuration per tenant. Example
<configuration>
<appSettings>
...
</appSettings>
<tenants>
<tenant key="1">
<add key="key1" value="false" />
</tenant>
<tenant key="2">
<add key="key1" value="value2" />
</tenant>
</tenants>
</configuration>
We dont use multi-tenancy in Octopus becose is only one installation per target but we cant imagine how to store and insert the configuration per tenant.
Any Ideas?
Full disclosure: I work for Octopus Deploy.
If I understand correctly you have a single binary that serves multiple tenants and web.config is used to specify which tenants are served by the application.
If so, then I would recommend splitting your application into 2 Octopus Projects. One which represents application code and one which represents configuration. The configuration Project would use multi tenancy in Octopus to add relevant entries to the web.config for each deployed tenant. This can be done using a config transformation or a custom script.
SO is a public forum so if you would like to share some sensitive information about your project then I would recommend you reach out to us via https://octopus.com/support.
Regards,

Startup.cs not needed on DEV machine but needed for deployment

I am developing an ASP.NET Web API v2 application. My application works fine from my DEV machine but when I go to deploy it to my server it gives the following errors.
The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- No assembly found containing a Startup or [AssemblyName].Startup class.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.
To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.
After searching Google, SO, and other sites I found adding a default Startup.cs class to my project fixed the issue. The problem is I don't know how.
What did adding Startup.cs do?
Why would my app compile and run on my development machine without Startup.cs?
This seems to involve OWIN but I was not even aware I was making use of any OWIN features.
This is most likely due to the way OWIN searches for its entry point (Startup class). In your dev environment you probably have a DLL in the project folder that has an OWIN Startup class. That dll is not being deployed as part of the deployment step and therefore doesn't exist in your deployed location.
Another posibility, along the same lines, is you're using .config transformations and you have defined a Startup class in your DEV config but not in your deployed config.
<appSettings>
<add key="owin:appStartup" value="StartupDemo.ProductionStartup" />
</appSettings>
OWIN Startup Class Detection might be informative.
MVC5 uses OWIN pipeline by default so it's "under the hood". Perhaps you migrated from a previous MVC site and that's why the Startup class was missing?
Cheers!

Add WCF Service Reference to Umbraco

Im currently using Umbraco 4.11 that is integrated to an asp.net mvc 3 application. Im trying to reference a wcf service in the umbraco project by selecting Add Service Reference in visual studio but I can not seem to access the service library once it is added. I tried to look into the object view browser and I couldn't find the object namespace for the wcf service. Am I missing something? Is this method of consuming wcf service in umbraco possible? I prefer not to use a separate project that uses a user control to access the wcf service since it seems to be tedious to do.
There is a warning when adding a service reference:
Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Could not load file or assembly 'umbraco, Version=1.0.4090.38017, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
You may want to setup the service reference in a separate project, then migrate the dll and the web.config settings. Then you should be able to access your web service via razor after adding using statements.
The problem is that the code file for the service isn't being generated because of a conflict with umbraco. You could alternatively generate the code file manually using svcutil.exe.

Adding AJAX-enabled WCF Service to the Solution throws an error

I am just trying to learn Ajax enabled WCF service, when I try to create a new web application and add new item "AJAX-enabled WCF Service" I get an error message that "The extension of type 'System.ServiceModel.Configuration.WebScriptEnablingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not registered in the extension collection 'behaviorExtensions'.
I had .net2.0/VS2005 and then I installed VS2008.
I was able to solve the problem after I reinstalled .Net 3.5. Thanks to Social.Microsoft forum.

Resources