Creating UWP app package results in errors - xamarin.forms

When I attempt to create a release UWP package for side loading I get the following error :-
1>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : System.NullReferenceException: Object reference not set to an
instance of an object. 1>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : at
System.Xml.Serialization.XmlSerializationWriterCodeGen.FindXmlnsIndex(MemberMapping[]
members) 1>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : at
System.Xml.Serialization.XmlSerializationWriterCodeGen.WriteStructMethod(StructMapping
mapping) 1>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : at
System.Xml.Serialization.XmlSerializationWriterCodeGen.GenerateMethod(TypeMapping
mapping) 1>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : at
System.Xml.Serialization.XmlSerializationCodeGen.GenerateReferencedMethods()
1>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : at
System.Xml.Serialization.XmlSerializationWriterCodeGen.GenerateEnd()
1>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : at
System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
XmlSerializerCompilerParameters parameters, Hashtable assemblies,
String outputDir, IEnumerable1 referenceDirectories, String
intermediateDir, Boolean loadAssembly) 1>C:\Program Files
(x86)\MSBuild\Microsoft\.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : at
System.Xml.Serialization.XmlSerializer.GenerateSerializer(Type[]
types, XmlMapping[] mappings, CompilerParameters parameters, String
outputDir, IEnumerable1 referenceDirectories, String intermediateDir,
Boolean loadAssembly) 1>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : at
System.Xml.Serialization.XmlSerializer.GenerateSerializer(Type[]
types, String outputDir, IEnumerable1 referenceDirectories, String
intermediateDir, List1 wcfSerializers, Boolean loadAssembly)
1>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : at SerializationAssemblyGenerator.Program.Main(String[]
args) 1>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x64\ilc\IlcInternals.targets(936,5):
error : Internal compiler error: One or more errors occurred.
My .appxmanifest file looks like:
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="XXXXXXXXXX" Publisher="XXXXXXXXXX" Version="1.0.4.0" />
<mp:PhoneIdentity PhoneProductId="XXXXXXXXXX" PhonePublisherId="XXXXXXXXXX" />
<Properties>
<DisplayName>XXXXXXXXXX</DisplayName>
<PublisherDisplayName>XXXXXXXXXX</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="XXXXXXXXXX.App">
<uap:VisualElements DisplayName="XXXXXXXXXX" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="XXXXXXXXXX" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<uap:Capability Name="phoneCall" />
<uap:Capability Name="picturesLibrary" />
<uap:Capability Name="userAccountInformation" />
<DeviceCapability Name="location" />
<DeviceCapability Name="proximity" />
<DeviceCapability Name="webcam" />
</Capabilities>
</Package>
Does anyone have any ideas why this happens?

Related

NLog "Input string was not in a correct format." using windows-identity

I am trying to log some information to database, but being kind of new to nlog config ( until now the default config from Tutorials worked fine) I am not sure what I am missing from my config to work.
I get this error when I app starts
2022-02-24 17:06:46.1375 Error Failed loading from config file location: C:\Repos\App\bin\Debug\netcoreapp3.1\NLog.config Exception: NLog.NLogConfigurationException: Exception when parsing C:\Repos\App\bin\Debug\netcoreapp3.1\NLog.config.
---> System.FormatException: Input string was not in a correct format.
at System.Text.StringBuilder.FormatError()
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(String format, Object[] args)
at NLog.NLogConfigurationException..ctor(Exception innerException, String message, Object[] messageParameters)
at NLog.Config.LoggingConfigurationParser.ConfigureObjectFromAttributes(Object targetObject, ILoggingConfigurationElement element, Boolean ignoreType)
at NLog.Config.LoggingConfigurationParser.ParseTargetElement(Target target, ILoggingConfigurationElement targetElement, Dictionary`2 typeNameToDefaultTargetParameters)
at NLog.Config.LoggingConfigurationParser.ParseTargetsElement(ILoggingConfigurationElement targetsElement)
at NLog.Config.LoggingConfigurationParser.ParseNLogSection(ILoggingConfigurationElement configSection)
at NLog.Config.XmlLoggingConfiguration.ParseNLogSection(ILoggingConfigurationElement configSection)
at NLog.Config.LoggingConfigurationParser.LoadConfig(ILoggingConfigurationElement nlogConfig, String basePath)
at NLog.Config.XmlLoggingConfiguration.ParseNLogElement(ILoggingConfigurationElement nlogElement, String filePath, Boolean autoReloadDefault)
at NLog.Config.XmlLoggingConfiguration.ParseTopLevel(NLogXmlElement content, String filePath, Boolean autoReloadDefault)
at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors)
--- End of inner exception stack trace ---
at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors)
at NLog.Config.XmlLoggingConfiguration..ctor(XmlReader reader, String fileName, LogFactory logFactory)
at NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfiguration(XmlReader xmlReader, String configFile, LogFactory logFactory)
at NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfigurationFile(LogFactory logFactory, String configFile)
at NLog.Config.LoggingConfigurationFileLoader.TryLoadLoggingConfiguration(LogFactory logFactory, String configFile, LoggingConfiguration& config)
My Config files looks like this
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwConfigExceptions="true"
internalLogLevel="trace"
internalLogFile="c:\temp\internal-nlog-AspNetCore3.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<!-- the targets to write to -->
<targets>
<!-- File Target for all log messages with basic details -->
<target xsi:type="File" name="allfile" fileName="c:\temp\nlog-AspNetCore3-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!-- File Target for own log messages with extra web details using some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="c:\temp\nlog-AspNetCore3-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}|" />
<!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection -->
<target xsi:type="Console" name="lifetimeConsole" layout="${MicrosoftConsoleLayout}" />
<target xsi:type="database" name="database"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|identity:${identity}|windows-identity:${windows-identity}">
<connectionString>
Data Source=MYCOMPUTER;Initial Catalog=DatabaseName;Integrated Security=True
</connectionString>
<commandText>
INSERT INTO SystemLogging(LogDate,LogLevel,LogLogger,LogMessage,LogMachineName, LogUserName, LogCallSite, LogThread, LogException, LogStackTrace)
VALUES(#time_stamp, #level, #logger, #message,#machinename, #user_name, #call_site, #threadid, #log_exception, #stacktrace);
</commandText>
<parameter name="#time_stamp" layout="${longdate}"/>
<parameter name="#level" layout="${level}"/>
<parameter name="#logger" layout="${logger}"/>
<parameter name="#message" layout="${message}"/>
<parameter name="#machinename" layout="${machinename}"/>
<parameter name="#user_name" layout="${windows-identity:domain=true}"/>
<parameter name="#call_site" layout="${callsite:filename=true}"/>
<parameter name="#threadid" layout="${threadid}"/>
<parameter name="#log_exception" layout="${exception}"/>
<parameter name="#stacktrace" layout="${stacktrace}"/>
</target>
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<!--Output hosting lifetime messages to console target for faster startup detection -->
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="lifetimeConsole, ownFile-web" final="true" />
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>
I know for a fact the problem is somewhere in line 28, layout of db connection.
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|identity:${identity}|windows-identity:${windows-identity}"
If I remove this line however I get an other error
"LayoutRenderer cannot be found: 'windows-identity'"
It feels like an obvious problem, however search the internet I could not find a solution. Anyone with more experience in NLog, can you share an example of DB Logging that uses Windows-Auth for db logging and not a username/password in connection string.
I've also tried ( added '' to windows-identity, but that didn't work either )
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|identity: '${identity}' | windows-identity: '${windows-identity}'"
Edit:
Updated config
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwConfigExceptions="true"
internalLogLevel="trace"
internalLogFile="c:\temp\internal-nlog-AspNetCore3.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.WindowsIdentity"/>
</extensions>
<!-- the targets to write to -->
<targets>
<!-- File Target for all log messages with basic details -->
<target xsi:type="File" name="allfile" fileName="c:\temp\nlog-AspNetCore3-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!-- File Target for own log messages with extra web details using some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="c:\temp\nlog-AspNetCore3-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}|" />
<!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection -->
<target xsi:type="Console" name="lifetimeConsole" layout="${MicrosoftConsoleLayout}" />
<target xsi:type="database" name="database"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|identity:${identity}|windows-identity:${environment-user}">
<connectionString>
Data Source=MYCOMPUTER;Initial Catalog=DatabaseName;Integrated Security=True
</connectionString>
<commandText>
INSERT INTO SystemLogging(LogDate,LogLevel,LogLogger,LogMessage,LogMachineName, LogUserName, LogCallSite, LogThread, LogException, LogStackTrace)
VALUES(#time_stamp, #level, #logger, #message,#machinename, #user_name, #call_site, #threadid, #log_exception, #stacktrace);
</commandText>
<parameter name="#time_stamp" layout="${longdate}"/>
<parameter name="#level" layout="${level}"/>
<parameter name="#logger" layout="${logger}"/>
<parameter name="#message" layout="${message}"/>
<parameter name="#machinename" layout="${machinename}"/>
<parameter name="#user_name" layout="${windows-identity:domain=true}"/>
<parameter name="#call_site" layout="${callsite:filename=true}"/>
<parameter name="#threadid" layout="${threadid}"/>
<parameter name="#log_exception" layout="${exception}"/>
<parameter name="#stacktrace" layout="${stacktrace}"/>
</target>
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<!--Output hosting lifetime messages to console target for faster startup detection -->
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="lifetimeConsole, ownFile-web" final="true" />
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>
So it turns out the layout is not working. I removed it and app would start with no erros. However I still had to add a rule in order to make logs in db. Here is the working version of the nlog file.
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwConfigExceptions="true"
internalLogLevel="trace"
internalLogFile="c:\temp\internal-nlog-AspNetCore3.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.WindowsIdentity"/>
</extensions>
<!-- the targets to write to -->
<targets>
<!-- File Target for all log messages with basic details -->
<target xsi:type="File" name="allfile" fileName="c:\temp\nlog-AspNetCore3-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!-- File Target for own log messages with extra web details using some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="c:\temp\nlog-AspNetCore3-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}|" />
<!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection -->
<target xsi:type="Console" name="lifetimeConsole" layout="${MicrosoftConsoleLayout}" />
<target xsi:type="database" name="database">
<connectionString>
Data Source=MYCOMPUTER;Initial Catalog=DbName;Integrated Security=True
</connectionString>
<commandText>
INSERT INTO SystemLogging(LogDate,LogLevel,LogLogger,LogMessage,LogMachineName, LogUserName, LogCallSite, LogThread, LogException, LogStackTrace)
VALUES(#time_stamp, #level, #logger, #message,#machinename, #user_name, #call_site, #threadid, #log_exception, #stacktrace);
</commandText>
<parameter name="#time_stamp" layout="${longdate}"/>
<parameter name="#level" layout="${level}"/>
<parameter name="#logger" layout="${logger}"/>
<parameter name="#message" layout="${message}"/>
<parameter name="#machinename" layout="${machinename}"/>
<parameter name="#user_name" layout="${windows-identity:domain=true}"/>
<parameter name="#call_site" layout="${callsite:filename=true}"/>
<parameter name="#threadid" layout="${threadid}"/>
<parameter name="#log_exception" layout="${exception}"/>
<parameter name="#stacktrace" layout="${stacktrace}"/>
</target>
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<logger name="*" minLevel="Trace" writeTo="database"/>
<!--Output hosting lifetime messages to console target for faster startup detection -->
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="lifetimeConsole, ownFile-web" final="true" />
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>
The NLog Database-Target doesn't have a Layout-property, that can be assigned. Instead use input parameter-collection.
WindowsIdentity-nuget-package is required for ${windows-identity} on NetCore, and must be included:
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.WindowsIdentity"/>
</extensions>
Maybe you are looking for ${environment-user} ?
See also: https://github.com/NLog/NLog/wiki/Windows-Identity-Layout-Renderer

How to disable CSRF in Spring Security 4 only for specific URL pattern through XML configuration?

How to disable CSRF in Spring Security 4 only for specific URL pattern through XML configuration?
Spring-security.xml
<security:http auto-config="true" use-expressions="true" pattern="/ext/**">
<csrf disabled="true" />
</security:http>
<security:http auto-config="true" use-expressions="true" authentication-manager-ref="authenticationManager">
<security:intercept-url pattern="/auth/**" access="hasAnyRole('ROLE_USER')" />
<security:form-login login-page="/login" authentication-success-handler-ref="loginSuccessHandler" authentication-failure-url="/login" login-processing-url="/j_spring_security_check" />
<security:logout invalidate-session="true" logout-url="/logout" success-handler-ref="logoutSuccessHandler" />
</security:http>
My code works fine if I use only one security:http block, but after I add another block it throws error as below:
Error
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter gov.in.controller.filter.LoginAdtAuthFailHdlr.usernamePasswordAuthenticationFilter; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter] is defined: expected single matching bean but found 2: org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0,org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#1
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 58 more
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter] is defined: expected single matching bean but found 2: org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0,org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#1
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1054)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
... 60 more
Could not achieve with just XML changes. Below worked for me
Change in Spring-security.xml
<security:http use-expressions="true" authentication-manager-ref="authenticationManager">
<security:intercept-url pattern="/auth/**" access="hasAnyRole('ROLE_USER')" />
<security:form-login login-page="/login" authentication-success-handler-ref="loginSuccessHandler" authentication-failure-url="/login" login-processing-url="/j_spring_security_check" />
<security:logout invalidate-session="true" logout-url="/logout" success-handler-ref="logoutSuccessHandler" />
<security:csrf request-matcher-ref="csrfSecurityRequestMatcher" />
</security:http>
CsrfSecurityRequestMatcher
public class CsrfSecurityRequestMatcher implements RequestMatcher {
private Pattern allowedMethods = Pattern.compile("^(GET|HEAD|TRACE|OPTIONS)$");
private RegexRequestMatcher unprotectedMatcher = new RegexRequestMatcher("/ext/**", null);
#Override
public boolean matches(HttpServletRequest request) {
if(allowedMethods.matcher(request.getMethod()).matches()){
return false;
}
return !unprotectedMatcher.matches(request);
}
}
You can have two (or more) filter chains:
<http pattern="/your-specific/**">
<!-- ... -->
<csrf disabled="true"/>
</http>
<http>
<!-- ... -->
</http>

Log4net not working in IIS7 on windows server 2008

Logs are not created on the server (Windows 2008) and IIS7. I had given absolute path as well as relative path.
I had given all rights to the log folder. I had included network user, IUsr and IIS_IUSRS, and gave permission to every one. also.
It is not writing logs to that folder
the entries on the web config is as follows
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
<log4net>
<logger name="GeneralLogger">
<level value="ALL" />
<appender-ref ref="RollingFile" />
</logger>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="C:\\vhosts\\staging.customerportal.com\\log\\CustomerPortal.log"/>
<appendToFile value="true"/>
<datePattern value="yyyyMMdd"/>
<rollingStyle value="Date"/>
<filter type="log4net.Filter.LevelRangeFilter">
<acceptOnMatch value="true"/>
<levelMin value="DEBUG"/>
<levelMax value="FATAL"/>
</filter>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %5rms %X{addr} %-22.22c{1} %-18.18M - %m%n"/>
</layout>
</appender>
</log4net>
I had tried giving single slash and well as double slash in the file value in web config nothing works.
The code in the global.asax.cs is
public class MvcApplication : System.Web.HttpApplication
{
private static log4net.ILog log = log4net.LogManager.GetLogger(typeof(MvcApplication));
protected void Application_Start()
{
log4net.Config.XmlConfigurator.Configure();
}
code in assemblyinfo.cs is
[assembly: XmlConfigurator(ConfigFile="web.config", Watch=true)]
I had tried with this code and also without this code in assemblyinfo.cs
It is not working.
Where as When I use absolute path in localhost the logs are written to that folder properly
It fails on the server
I had tried both these options in the controller file
//private static log4net.ILog log =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) ;
private static log4net.ILog log = log4net.LogManager.GetLogger("GeneralLogger");
I had tried a path which does not exists, it did not created folder.
Please help me. Please help me how to enable logs using log4net in server
You are initializing your logger before configuring the logmanager (actually you configuring it twice) by calling the Configure on Application_Start.
Option 1:
public class MvcApplication : System.Web.HttpApplication
{
private static log4net.ILog log = log4net.LogManager.GetLogger(typeof(MvcApplication));
protected void Application_Start()
{
//Remove: log4net.Config.XmlConfigurator.Configure();
}
And keep:
[assembly: XmlConfigurator(ConfigFile="web.config", Watch=true)]
Option 2:
public class MvcApplication : System.Web.HttpApplication
{
private static log4net.ILog log;
protected void Application_Start()
{
log4net.Config.XmlConfigurator.Configure();
log = log4net.LogManager.GetLogger(typeof(MvcApplication));
}
And remove:
//Remove: [assembly: XmlConfigurator(ConfigFile="web.config", Watch=true)]

Unity Interception MethodSignatureMatchingRule could not be resolved

Im using Unity (3.0) interception to add some crosscutting concerns to my application. Somehow I can't use the MethodSignatureMatchingRule in my configuration getting this error message:
{"The type name or alias MethodSignatureMatchingRule could not be resolved. Please check your configuration file and verify this type name."}
My configuration:
<?xml version="1.0"?>
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration" />
<alias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity" />
<containers>
<container name="MyContainer">
<extension type="Interception"/>
<interception>
<policy name="EhabAspect">
<matchingRule name="MethodSignatureMatchingRule" type="MethodSignatureMatchingRule">
<constructor>
<param name="methodName" value="Receive" type="string"/>
</constructor>
</matchingRule>
<callHandler ... (omitted)
</policy>
</interception>
<register type="IMyClass" mapTo="MyClass">
<lifetime type="singleton" />
<interceptor type="InterfaceInterceptor"/>
<policyInjection/>
</register>
</container>
</containers>
</unity>
The same configuration with the NamespaceMatchingRule works fine.
My assembly contains a reference to
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.Unity
Microsoft.Practices.Unity.Configuration
Any suggestions?
I was facing the same problem here. I solved using the full qualified name of the of the class.
<matchingRule name="AuthorizationMethod" type="Microsoft.Practices.Unity.InterceptionExtension.MethodSignatureMatchingRule, Microsoft.Practices.Unity.Interception">
<constructor>
<param name="methodName" value="Authenticate" type="string"/>
<param name="parameterTypeNames" dependencyName="EmptyArray"/>
</constructor>
</matchingRule>

Using compiler constants with <compc /> ant task

I'm converting an existing build script from <mxmlc /> to <compc /> to generate a swc.
However, the build is failing, giving the error:
[compc] C:\xxxx\LogViewer.mxml(32): Error: Access of undefined property VERSION.
[compc]
[compc] private static const VERSION:String = CONFIG::VERSION;
In my ant task, I have the following defined:
<compc compiler.as3="true" output="${output.dir}/${swc.name}.swc" incremental="true" fork="true" maxmemory="512m" compiler.show-deprecation-warnings="false">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<source-path path-element="${srcdir}" />
<include-sources dir="${srcdir}" includes="*" />
<external-library-path dir="${swc.libs.dir}" append="true">
<include name="*.swc" />
</external-library-path>
<external-library-path dir="${output.common.swc.dir}" append="true">
<include name="*.swc" />
</external-library-path>
<compiler.define name="CONFIG::VERSION" value="${build.version}" />
<compiler.define name="CONFIG::RELEASE" value="${config.release}" />
<compiler.define name="CONFIG::DEBUG" value="${config.debug}" />
<compiler.define name="CONFIG::AUTOMATION" value="false" />
</compc>
This approach worked fine with the task, but is now failing.
What's the correct way to use compiler constants with compc?
String values need to be put in single quotes. For instance:
<compiler.define name="CONFIG::VERSION" value="'${build.version}'" />
The Flex Ant tasks really are incredibly frustrating, mainly due to the lack of documentation. I struggled with this for a while until I figured it out.
We do something similar in our build, and the only difference I can see is that we don't have the compiler bit:
<define name="CONFIG::build" value="5" />

Resources