I have configured NHibernate to output the SQL it generates to the console. I have added the following to the app.config of the DLL containing the integration tests I want to run from NUnit:
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<nhibernate>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<add key="hibernate.show_sql" value="true" />
</nhibernate>
However, the SQL is still not being output to Console.Out. Can anyone think of another setting I might need to set to view the SQL resulting from my NHibernate queries?
Did you try using a sepparate xml config? http://nhibernate.info/doc/howto/various/configure-log4net-for-use-with-nhibernate.html
Related
Recently I posted a couple of errors I was having, relating to app.config in a VB project. Andrew Morton kindly pointed me to an existing answer which resolved the first part of the issue, but I've since found that I still can't add/update variables in app.config via the Settings dialog in the project properties, nor can the Settings dialog read the app.config file.
The error message is:
an error occurred while reading the app.config file. the file might be corrupted
If I manually change the variable in app.config the program I'm coding still finds the old value as it's taking it from Settings.Designer.vb, and that's not getting updated when I change the variable in Settings as the platform isn't reading the app.config.
I've (again) run the app.config through an XML checker, all fine. I read one solution for this issue, which suggested the cause can be duplicate elements in the 'sectionGroup' area of app.config, but mine doesn't appear to have duplicate elements (app.config posted).
Steps I have tried are:
Removed and re-added the project from the solution.
Updated VS.
Repaired VS.
Deleted the app.config file and the variables from the Project Properties - System dialog, then added a new app.config and recreated the variables in the System dialog.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler"/>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" >
<section name="Doghunter.My.MySettings" type="System.Configuration.ClientSettingsSection, System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" requirePermission="false" />
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="Doghunter"/>
</sharedListeners>
</system.diagnostics>
<applicationSettings>
<Doghunter.My.MySettings>
<setting name="TestKey" serializeAs="String">
<value>Henry</value>
</setting>
<setting name="NewKey" serializeAs="String">
<value>Moscow</value>
</setting>
</Doghunter.My.MySettings>
</applicationSettings>
</configuration>
Rebuilding the project as a Windows Forms Application (.Net Framework 4.7.2) resolved it.
Originally chose 'plain' Windows Forms Application, which used 5.0
No idea why this is the case, but now works so all good.
Using Visual Studio 2015 & Sitecore 8.0
I have created a new MVC project with .Net Framework 4.6.1, copied, and referenced the Sitecore.kernel.dll & Sitecore.mvc.dll. Replaced the existing web.config & global.asax with the sitecore files.
Added a plain HTML page in the solution and tried to browse it (from VS). The page opens with this error
Could not load file or assembly 'System.Web.Http, Version=5.1.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified.
This HTML page is not published to Sitecore yet. I'm guessing, the Sitecore.mvc.dll wants MVC 5.1.0 and the MVC in VS project is 4.0.
So, I tried the following steps.
Run install package command in package manager console for MVC 5.1.1 which shows the error
Unable to load the service index for source
https://api.nuget.org/v3/index.json.
Deleted the %AppData%\NuGet\nuget.config and restarted VS2015
Manually browsed https://api.nuget.org/v3/index.json, but the page doesn't load - Secure connection failed. But this - http://api.nuget.org/v3/index.json will promt to download the json. So, in the nuget changed https to http, but its the same error - Unable to load the service index...
I'm not even able to start my first Sitecore MVC project when this happens.
I replaced the sitecore web.config with the regular VS project's web.config and now I'm able to browse the page. I set its Copy To Output Directory to Do not copy, so that it will not get published.
Will I be able to proceed with my Sitecore development this way without any major issues in future.
You need to do a few things to fix this:
Your VS project should be updated to have the web.config file from the Sitecore installation. You must have the Sitecore version of that file or Sitecore will not run correctly
You should add a binding redirect for the MVC file that makes everything use the latest version:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
etc....
</runtime>
Make sure that the web.config file in your /views folder contains the correct versions of all the MVC assemblies. This is mine for a .net 4.6 application:
<configSections>
<sectionGroup name="system.web.webPages.razor"
type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host"
type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
requirePermission="false" />
<section name="pages"
type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host
factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="Sitecore.Mvc" />
<add namespace="Sitecore" />
</namespaces>
</pages>
</system.web.webPages.razor>
Once that is done, your Sitecore installation should pick up the latest MVC binaries correctly.
I'm trying to precompile razor views but during the build VS2010 throws errors such as "#ViewBag does not exist in the current context." The project builds and runs fine when views are not precompiled.
In order to turn on view compilation I set the following node in the project file:
<MvcBuildViews>true</MvcBuildViews>
The section below exists in the Views Web.config file.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Xml"/>
<add namespace="System.Xml.Linq"/>
</namespaces>
</pages>
</system.web.webPages.razor>
Any ideas why the project won't build?
Geeze, do I ever feel like an idiot. Turns out there were some cshtml files in a _temp folder that resided inside of the project folder. Even though the folder was excluded from the solution the compiler was picking up the files contained therein. Moving that _temp file out of the project folder fixed the issue.
I am new to Entity Framework and Linq to Entities and I want to try LinqPad but I can't figure out how to make a connection to the edmx model I have created.
I have an MVC project and I added an ADO.Net Entity Data Model against a SQL Sever database ( a Development server, not one on my local machine) Did a Build.Right click in my designer surface and Add Code Generation Item. That has given me two .tt folders, one for my dbContext class, one with all my classes.
Open LinqPad click on Add Connection. Point to the .dll file in my solutions bin folder, then in the Full Type Name of dbContext I choose the entity I created. Now is whee I am having trouble making this work. I point to the solution web.config file and when I click the Test button I get an error saying "Could not load file or assembly 'Entity Framework version=..." & "The system cannot find the file specified. (C:\users..\web.config line 9" Any ideas?
I took configSections away from config file and connection works.
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
I've had this exact problem with LinqPad 4.42.01. My project is a web project using an EF5 data assembly. I ended up creating a linqPad.config file (below) in the web projectMy and it works great.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<remove name="MySqlServer"/>
<add name="MySqlServer" connectionString="Data Source=mydb;Initial Catalog=mycat;User ID=iamuser;Password=soopersekret;Trusted_Connection=False" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
I have an WCF Service Application and the web.config is set to debug mode (debug = true):
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
I would like to set that to "debug=false" via MSBuild Extension Pack (version 3.5.8.0), so that the released version is always automatically in non-debug mode.
Obviously I need to use the XmlFile class, but it doesn't do anything.
My build file looks like this:
<Target Name="Test">
<MSBuild.ExtensionPack.Xml.XmlFile TaskAction="UpdateAttribute" File="$(MSBuildProjectDirectory)\$(BuildDir)\ServiceClient\web.config" XPath="/configuration/system.web/compilation[#name='debug']" InnerText="false"/>
</Target>
When I run the build script, I only see this:
Test:
XmlFile: C:\MyProject\Build\ServiceClient\web.config
Update Attribute: /configuration/system.web/compilation[#name='debug']. Value:
No errors, no warnings...nothing.
I can see that MSBuild found the web.config and did something with it, because "Date Modified" in the Explorer is set to right now, which wasn't the case before I ran the script. But there is no visible change in the file. I used a diff tool to compare the file versions before and after MSBuild, and they are identical.
I also tried to set Key and Value instead of InnerText, but that doesn't help either.
Any idea what I'm doing wrong?
Try this:
<Target Name="Test">
<MSBuild.ExtensionPack.Xml.XmlFile TaskAction="UpdateAttribute" File="web.config" XPath="/configuration/system.web/compilation" Key="debug" Value="false" />
</Target>
I am using extension pack version 3.5.8.0