I am using Service Bus in my project. I am referring Version 2.0.0.0 dll.
When I add following tag in my app.config everything works fine
<extensions>
<bindingExtensions>
<add name="netTcpRelayBinding"
type =
"Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement,
Microsoft.ServiceBus, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
but as soon as I remove this tag, it gives following error
Configuration binding extension 'system.serviceModel/bindings/netTcpRelayBinding' could not be found.
Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
Is it mandatory to provide this tag because on some other machine it is working fine without this tag.
This is required for WCF to be able to load this binding from the correct dll. There are cases where you can add this to other config files like machine.config and WCF will pick it from there and hence the app will work without having it in the app.config file.
Related
I'm currently attempting to convert an older project from VS2013/MVC3 to use VS2015/MVC5, and I've ran into a problem where any old ASPX view (.aspx/.ascx) that sets a strongly-typed model causes a build error.
I've tried with a clean project made from scratch, and the same error occurs, so it makes it fairly simple to reproduce:
File > New > Project.
Create a new ASP.NET Web Application Project.
Select ASP.NET 4.6 Templates > MVC, then click OK.
Create an .ascx file in Views\Home. (Note that VS2015 doesn't have tooling to create such a file, so you'll have to create a text file and rename it or something.) It should contain:
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TestClass>" %>
Either create a new model class (like I did with TestClass), or use one of the pre-built Identity models contained in the project.
Add a call to #Html.Partial("<your_user_control>") to Home/Index.cshtml.
Run the project.
This is what I get when I do the above:
This is the version of VS2015 I'm using:
I've tried searching for every possible permutation of search that could uncover this issue, but all I could find is posts confirming that ASPX/ASCX views are indeed supported in VS2015/MVC5, or posts about old versions of MVC.
Any solutions?
A generic type declaration written in C# like ViewUserControl<TestClass> has to go into a C# code-behind file. Otherwise, you have to specify a CLR type name:
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl`1[[MyWebApplication.Models.TestClass, MyWebApplication]]" %>
Turns out you need to ensure a web.config (either your project's base one, or the ones in your base Views folder and the ones for all of your areas) has the following in there somewhere:
<system.web>
...
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
...
</system.web>
The web.config that come with the default project created in VS2015 does not include this, presumably because they assume (and probably rightly so) greenfield projects won't use the Web Forms view engine.
I found the above by double-checking the ASP.NET MVC 4->5 upgrade docs again.
I have a website (not web role) that I'm deploying to Azure, using the Basic tier. The web.config file has the following auto-generated section for website settings:
<applicationSettings>
<MySite.Web.Properties.Settings>
<setting name="MySetting" serializeAs="String">
<value>coolValue</value>
</setting>
</MySite.Web.Properties.Settings>
</applicationSettings>
I'm trying to override the value of MySetting in Azure's Web Apps -> MySite -> Configure -> app settings section. The idea being that the live website has a different value than the development version. I'm trying to avoid storing the live website's value in the web.config file (nor doing transforms).
I've tried the following values in the app settings section of the azure web app configuration section:
MySetting = somethingElse
MySite.Web.Properties.Settings.MySetting = somethingElse
Neither of these things worked. I like the new strongly-typed settings class in .NET, and don't really want to flatten the app settings out (using the old way).
Does anyone know how to override these types of settings in Azure?
Have you added the applicationSettings to the section group?
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Tools.Instrumentation.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
One alternative is to set the App Settings from the Azure Portal. Go to the Azure Portal->Navigate to your website->Settings->App Settings and set the key, value pair there.
All settings will show up as environment variables, so you can set different values for the same settings in your test and production environments.
See here for more info:
http://azure.microsoft.com/blog/2013/07/17/windows-azure-web-sites-how-application-strings-and-connection-strings-work/
I asked around Microsoft's support & could not get an answer for this issue as I wanted to do this too. Fortunately while trying to better understand Microsoft's Web Deploy I discovered how to do this.
First, you'll need to use an external config file instead of just adding them into the web.config file. In your web.config file replace the following:
<applicationSettings>
<MySite.Web.Properties.Settings>
<setting name="MySetting" serializeAs="String">
<value>coolValue</value>
</setting>
</MySite.Web.Properties.Settings>
</applicationSettings>
Use an external configuration file like this instead:
<applicationSettings>
<MySite.Web.Properties.Settings configSource="BusinessLogic.config" />
</applicationSettings>
Also in your web.config file you will need to add the following to your configSections:
<configSections>
<sectionGroup name="applicationSettings">
<section name="MySite.Web.Properties.Settings" />
</sectionGroup>
</configSections>
You can read the MSDN article for more on this if need be.
In your BusinessLogic.config file, located in your root with your web.config file you would add your settings:
<MySite.Web.Properties.Settings>
<setting name="SecretPassword" serializeAs="String">
<value>1234567890abc!##</value>
</setting>
</MyApplication.Properties.Settings>
Now manually add this same BusinessLogic.config file to your site on Azure with the settings you want it to have in Azure.
Finally open up your .csproj file and look for the following XML configuration:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Within there you can exclude files from deployment by adding a line like this:
<ExcludeFilesFromDeployment>BusinessLogic.config</ExcludeFilesFromDeployment>
If you need to exclude more files, you can separate them with a semicolon.
Now in my case when I commit all these files to my git repository, Azure will automatically grab them & put them in a temporary file where it will build the project and then deploy it to the folder where the website lives. Upon deploying it will notice to ignore the BusinessLogic.config file and the file you manually placed in Azure will be used instead.
I have a strange situation:
I have configured custom log4net Appender to write to Azure Table storage. I have WorkerRole and WebRole. Both roles use osFamily="3" (Windows Server 2012), I use .NET 4.5 in both and use ASP.NET MVC4 for the WebRole. Everything is configured and works fine locally - both the worker and the web role are logging correctly. However, when I deploy to Azure, only Worker role logs successfully, webrole does not produce any logs (any!), while it should.
I have configured log4net on the WebRole to debug and emit log4net debugging data into the Trace to check for some issues, but it sends no errors/warnings. Nor it sends logging messages.
Here is the log produced by log4net debugging (stripped sensitive data):
log4net: log4net assembly [log4net, Version=1.2.11.0, Culture=neutral,
PublicKeyToken=669e0ddf0bb1aa2a]. Loaded from
[D:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET
Files\root\59a01799\5b6b1a2\assembly\dl3\8d97587f\b9d49402_c202ce01\log4net.dll].
(.NET Runtime [4.0.30319.18010] on Microsoft Windows NT 6.2.9200.0)
log4net: defaultRepositoryType
[log4net.Repository.Hierarchy.Hierarchy] log4net: Creating repository
for assembly [_my_referenced_assembly_, Version=1.3.0.20282,
Culture=neutral, PublicKeyToken=null] log4net: Assembly
[_my_referenced_assembly_, Version=1.3.0.20282, Culture=neutral,
PublicKeyToken=null] Loaded From
[D:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET
Files\root\59a01799\5b6b1a2\assembly\dl3\8cc98c20\594c5b41_6f07ce01_my_referenced_assembly_.dll]
log4net: Assembly [_my_referenced_assembly_, Version=1.3.0.20282,
Culture=neutral, PublicKeyToken=null] does not have a
RepositoryAttribute specified. log4net: Assembly
[_my_referenced_assembly_, Version=1.3.0.20282, Culture=neutral,
PublicKeyToken=null] using repository [log4net-default-repository] and
repository type [log4net.Repository.Hierarchy.Hierarchy] log4net:
Creating repository [log4net-default-repository] using type
[log4net.Repository.Hierarchy.Hierarchy] Loaded
"Microsoft.WindowsAzure.ServiceRuntime, Version=1.8.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" Getting
"_some_setting_1_" from ServiceRuntime: PASS (_my_value1_). Getting
"_some_setting_2_" from ServiceRuntime: PASS (_my_value2_). Getting
"_some_setting_3_" from ServiceRuntime: PASS (_my_value3_). Getting
"Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" from
ServiceRuntime: PASS (_my_conn_string_). Getting "_some_setting_4_"
from ServiceRuntime: PASS (_my_value4_). log4net: Creating repository
for assembly [_my_WEB_assembly_, Version=1.3.0.20283, Culture=neutral,
PublicKeyToken=null] log4net: Assembly [_my_WEB_assembly_,
Version=1.3.0.20283, Culture=neutral, PublicKeyToken=null] Loaded From
[D:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET
Files\root\59a01799\5b6b1a2\assembly\dl3\f695181f\98c73242_6f07ce01_my_WEB_assembly_.dll]
log4net: Assembly [_my_WEB_assembly_, Version=1.3.0.20283,
Culture=neutral, PublicKeyToken=null] does not have a
RepositoryAttribute specified. log4net: Assembly [_my_WEB_assembly_,
Version=1.3.0.20283, Culture=neutral, PublicKeyToken=null] using
repository [log4net-default-repository] and repository type
[log4net.Repository.Hierarchy.Hierarchy] log4net: repository
[log4net-default-repository] already exists, using repository type
[log4net.Repository.Hierarchy.Hierarchy] Getting "acs:idps" from
ServiceRuntime: FAIL. Getting "acs:idps" from ConfigurationManager:
PASS ([my_value]).
Here is sample of both my app.config (for worker) and web.config (for web role) files (I also set this into WaIISHost.config just in case, but the result is still the same - totally muted WebRole):
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
...
</configSections>
...
<log4net>
<appender name="AzureTableStoreAppender" type="_MyAssembly_.Logging.AzureTableStorageAppender, MyAssembly">
</appender>
<root>
<level value="ALL" />
<appender-ref ref="AzureTableStoreAppender" />
</root>
</log4net>
</configuration>
I configure log4net via the assembly level attribute. Thus in Worker role assembly I have:
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
And in web role I have:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Web.config", Watch = true)]
As I said, everything works fine and writes table entities fine when run locally. My Local Environemtn is Windows 8 Pro, running the web roles in IIS Server (not IIS Express), which is IIS8. I also tried marking the WebRole executionContext to elevated but still nothing happens. It is like a black hole for log4net.
My custom appender is defined in a separate Assembly, .net Framework 4.5 (full), of type Class Library which is referenced in both Web and Worker projects. As already said - locally everything works fine. The assembly that defines my custom appender is definitely loaded, because it also contains business logic of my web app, which works deployed in Azure as well.
UPDATE
Interesting discovery. When I use Debug build configuration everything works everywhere (azure web role also). But when I use Release configuration (which is default for packaging and production code) I can't seem to be able to make log4net working anywhere. Meaning that I can't make Log4Net running even locally with Release config. No exceptions are being raised, no errors being logged. As strange as it can be...
It turns out the Release build is causing issues. According to the log4net's FAQ section, configuring log4net via assembly level attribute may behave different in DEBUG and RELEASE configurations.
In my setup I was using a static readonly property (of a base controller) initialized upon declaration. This seemed to bug the logger configuration. I moved my Logger instance to an instance property of my Web Application type and changed my controller property to just return Application's property. Now everything is working fine in all build configurations.
Regarding Azure, I have run into the same problem. I encountered that when in Release configuration nothing is being logged, even if locally both Debug and Release work fine.
My problem was not a configuration of log4net but rather its initialization.
I had it that way:
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
so then I replaced it with following line and it helped:
private readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(WorkerRole));
Up until now I have only worked with this web.config within Visual Studio. However I am now trying to publish my website to IIS and there are errors associated with my web.config. It seems that it crashes on configuration data for a module.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<phpNet>
<classLibrary>
<add assembly="php_mcrypt.mng, Version=3.0.0.0, Culture=neutral, PublicKeyToken=4ef6ed87c53048a3" section="mcrypt" />
<add assembly="php_curl.mng, Version=3.0.0.0, Culture=neutral, PublicKeyToken=4ef6ed87c53048a3" section="curl" />
</classLibrary>
<scriptLibrary/>
</phpNet>
</configuration>
error:
This screenshot is when trying to double click on any "Feature" within the "Feature View" of IIS. However if i just hit the website via a browser the error is the same:
The configuration section 'phpNet' cannot be read because it is
missing a section declaration
phpNet is for Phalanger, and the extension should be installed but I do not know how to check that. Like I said though, this web.config and phalanger worked fine within visual studio so Im not sure whats wrong. Especially since the installer did install the samples in iis.
You are missing configuration section definition
<configSections>
<section name="phpNet" type="PHP.Core.ConfigurationSectionHandler, PhpNetCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0a8e8c4c76728c71" />
Without this, .NET does not know the 'phpNet' configuration section.
Also this means, you don't have Phalanger installed using setup.exe. Here are some information about using Phalanger without proper installation (important is the part about configuration) http://www.php-compiler.net/blog/2011/installation-free-phalanger-web
I found this posting http://crdevelopment.net/2012/06/12/fixing-iis-error-the-configuration-section-system-web-extensions-cannot-be-read-because-it-is-missing-a-section-declaration/
which led me to check the application pools.
At which point I noticed there where multiples. I selected the phalangerAppPool and that got rid of my error, but brought about a new one.
Handler “PageHandlerFactory-Integrated” has a bad module
“ManagedPipelineHandler” in its module list
However that error was alot easier to resolve (fix)
Has anyone used WSP Builder to package a solution that uses the Config Store (http://www.codeplex.com/SPConfigStore) and deploys to the bin directory of the web application?
When I try to referecne the config store in my code behind file I get this exception...
System.Security.SecurityException: That assembly does not allow partially trusted callers
I've added the partially trusted callers attribute to my project
[assembly: AllowPartiallyTrustedCallers()]
and the sharepoint permissions attributes on my methods
[SharePointPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, Impersonate = true)]
[SharePointPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, ObjectModel = true)]
But this hasn't seem to have done anything, I've also specified a custom CAS policy with the correct IPermission
<IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" ObjectModel="True" UnsafeSaveOnGet="True" Unrestricted="True" />
And still no success, surely other people have done this, I must be missing something
I'm using WSP Builder version 1.0.5.
You have added the [assembly: AllowPartiallyTrustedCallers()] to YOUR assembly, so your assembly WILL allow for partially trusted callers to call IT.
But the ConfigStore itself does not have that attribute.
Is it possible to add your DLL to the GAC? (easy way out).
Or add the [assembly: AllowPartiallyTrustedCallers()] to the ConfigStore project as well..
Did you add the assembly to the web.config SafeControls section?
<SafeControl Assembly="Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.Office.Server.Search.WebControls" TypeName="*" Safe="True" />
Also you may need to lower the trust level in the web.config:
<trust level="WSS_Minimal" originUrl="" />
See the MSDN docs for ASP.Net and SharePoint trust levels.