App.config file and section type - prism

I have a problem. I'm learning from MTaulty's video: http://channel9.msdn.com/blogs/mtaulty/prism--silverlight-part-2-dependency-injection-with-unity. And I have a problem with .config file which he creates at 18:00 min. There is no possibility to see what is in
<section type=".."
I wrote:
type="Microsoft.Practises.Unity.Configuration.UnityConfigurationSection, Microsoft.Practises.Unity.Configuration" />
but it does not work. I don't have idea what is wrong. I have a mistake that VisualStudio can't load file'Microsoft.Practises.Unity.Configuration and find a file.
thanks for help!

If you want to specify modules via config file the Prism Guide on MSDN does a good job explaining that.
Quote from the Guide
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="modules"
type="Microsoft.Practices.Prism.Modularity.ModulesConfigurationSection, Microsoft.Practices.Prism"/>
</configSections>
<modules>
<module assemblyFile="ModularityWithUnity.Desktop.ModuleE.dll" moduleType="ModularityWithUnity.Desktop.ModuleE, ModularityWithUnity.Desktop.ModuleE, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="ModuleE" startupLoaded="false" />
<module assemblyFile="ModularityWithUnity.Desktop.ModuleF.dll" moduleType="ModularityWithUnity.Desktop.ModuleF, ModularityWithUnity.Desktop.ModuleF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="ModuleF" startupLoaded="false">
<dependencies>
<dependency moduleName="ModuleE"/>
</dependencies>
</module>
</modules>
</configuration>

For Prism 6.0 section type has changed to Prism.Modularity.ModulesConfigurationSection, Prism.Wpf
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="modules" type="Prism.Modularity.ModulesConfigurationSection, Prism.Wpf" />
</configSections>
<modules>
*** register your modules here ****
</modules>
</configuration>

I had a problem with App.config mapping. The section type was invalid. The right one is:
<section name="modules" type="Microsoft.Practices.Prism.Modularity.ModulesConfigurationSection, Microsoft.Practices.Prism.**Composition**"/>
Hope it helps.

Related

Web.config redirect to another URL without trailing slash

Very strange thing; I'm using the following in web.config file to redirect everything from one domain to specific page on another domain:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://www.example.com/my-page.html" />
</system.webServer>
</configuration>
However, trailing slash is appended to the URL, resulting in a 404:
http://www.example.com/my-page.html/
How can I force redirect WITHOUT the trailing slash?
Thanks!
add exactDestination="true" to your config. It should look like this
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://www.example.com/my-page.html" exactDestination="true" />
</system.webServer>
</configuration>

How to create a simple administration panel for my joomla plugin

I think the problem lies in my xml.
<?xml version="1.0" encoding="UTF-8"?>
<extension version="2.5" type="plugin" group="content">
<install>
<name>Content - eya</name>
<author>eya</author>
<creationDate>February 2013</creationDate>
<copyright>(C) 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>anigag#grzeit.com</authorEmail>
<authorUrl>www.eya.com</authorUrl>
<version>2.5.0</version>
<description>Adds eya plugin ot your site</description>
<files>
<filename plugin="eya">eya.php</filename>
</files>
</install>
<administration >
<filename>admin.php</filename>
</administration>
</extension>
This is my main php file that executes the content:eya.php.
I have got another file (admin.php) that takes 2 session variables from eya.php and put them in an iframe. There are two problems. One is that I dont know if the eya.php runs everytime before admin.php (or at least once to set the session variables). The second problem is that I dont know how to display only the admin.php and nothing else.
to build an admin interface for your plugin just add the config part to your xml
<config>
<fields name="params">
<fieldset name="basic">
<field name="testfield" type="text" default="mytest" label="field_label" description="field_description" />
</fieldset>
</fields>
</config>
but I didn't get the part of your admin.php/eya.php

Spring module in JBoss 7

I'm trying to set up Spring 3.0.6 libraries as a module in JBoss 7.
I have all of the jars in modules/org/springframework/main along with the following module.xml
<module xmlns:"urn:jboss:module:1.0" name="org.springframework">
<resources>
<resource-root path="org.springframework.beans-3.0.6.RELEASE.jar"/>
...
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.servlet.api"/>
<module name="org.apache.commons.logging"/>
</dependencies>
</module>
I added org.springframework to the Dependencies line in my MANIFEST.MF
When I deploy the app the following exception is thrown while parsing my spring-servlet.xml file (sorry, this is from a system that is not networked)
SAXParseException: ... Cannot find the declaration of element 'beans'
My first thought was that the module is not being used but if I remove org.springframework from my Dependencies line it fails to find org.springframework.web.context.ContextLoaderListener
Everything works fine if I put the jars in WEB-INF/lib instead of using the module.
spring-servlet.xml contains the following schema reference
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
so I put spring-beans-3.0.xsd in the same directory as spring-servlet.xml and modified the xml to
http://www.springframework.org/schema/beans spring-beans-3.0.xsd
but still no luck.
Anybody have an idea of why the class files are found but the xsd files are not?
Just in case the link that was given in the comments goes away, the problem is that
Problem:
The namespace configuration files are in META-INF, but that directory
is not visible (nor is it configurable via
jboss-deployment-structure.xml)
Solution:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
<module name="org.apache.commons.logging"/>
<module name="org.springframework" >
<imports>
<include path="META-INF**"/>
<include path="org**"/>
</imports>
</module>
</dependencies>
</jboss-deployment-structure>
Was facing the exact same issue. Had set up a spring module on JBoss 7 and then when deploying my application, was facing the below warning:
Failed to read schema document
'http://www.springframework.org/schema/beans/spring-beans-3.2.xsd'
I understood the spring context file was unable to access the schema definitions from the spring jars, after reading the link in the comments above. And hence, the application was not getting deployed. But the solution given there did not work for me. But the below code in the jboss-deployment-structure.xml resolved the issue.
Solution
<module name="org.springframework.spring" meta-inf="export" export="true" />
Added meta-inf="export" attribute.

Custom web part deployment produces 'Cannot import this webpart' error

I have built an empty SharePoint project in Visual Studio 2010 with some custom web parts in it. When I've tested these on my local development machine they can be added to a page without any trouble.
When I deploy the wsp via PowerShell to a remote SharePoint server, the web parts show in the web part gallery but adding one to a page gets me the error 'Cannot import this web part'. The logs have no further information in them. As per some answers I've found via Google, I've checked there is no code in Init. All initial processing is done within CreateChildControls (although I would have thought if this were the cause, I would get the same error on my local machine).
I originally asked this question at https://sharepoint.stackexchange.com/questions/11820/custom-web-part-deployment-produces-cannot-import-this-webpart-error. From the suggestions I received I decided to create a fresh project where I had done minimal coding.
The new project has just one simple label web part. The code for the web part is
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace TestWebParts.TestHelloWorld
{
[ToolboxItemAttribute(false)]
public class TestHelloWorld : WebPart
{
protected override void CreateChildControls()
{
Label lblThis = new Label();
lblThis.Text = "Testing web part";
Controls.Add(lblThis);
}
}
}
The .webpart file in the project is
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="TestWebParts.TestHelloWorld.TestHelloWorld, $SharePoint.Project.AssemblyFullName$" />
<importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">TestHelloWorld</property>
<property name="Description" type="string">My WebPart</property>
</properties>
</data>
</webPart>
</webParts>
I have checked that a safe control entry has been added. I have added CAS policies to the project (as these will be deployed to the bin rather than the GAC). The package manifest looks like this
<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/">
<CodeAccessSecurity>
<PolicyItem>
<PermissionSet class="NamedPermissionSet" version="1" Description="Permission set for ECB">
<IPermission class="AspNetHostingPermission" version="1" Level="Minimal" />
<IPermission class="SecurityPermission" version="1" Flags="Execution,ControlPrincipal,ControlAppDomain,ControlDomainPolicy,ControlEvidence,ControlThread" />
<IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
version="1" ObjectModel="True" />
<IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="UserName" />
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" PathDiscovery="*AllFiles*" />
<IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" PathDiscovery="*AllFiles*" />
</PermissionSet>
<Assemblies>
<Assembly Name="$SharePoint.Project.AssemblyName$" Vers7ion="$SharePoint.Project.AssemblyVersion$" PublicKeyBlob="$SharePoint.Project.AssemblyPublicKeyBlob$"/>
</Assemblies>
</PolicyItem>
</CodeAccessSecurity>
</Solution>
The .wsp installs fine on the dev machine I am trying to get this running on. When I try to view the web part in the Web Part Gallery I get the message "Cannot import this web part" as shown above. I have confirmed that the .dll is in the bin directory. The web.config file holds this entry
<SafeControl Assembly="TestWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8d63a878e7c304c2" Namespace="TestWebParts.TestHelloWorld" TypeName="*" Safe="True" SafeAgainstScript="True" />
When I view the webpart xml from the Web Part Gallery I see
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="TestWebParts.TestHelloWorld.TestHelloWorld, TestWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8d63a878e7c304c2" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">TestHelloWorld</property>
<property name="Description" type="string">My WebPart</property>
</properties>
</data>
</webPart>
</webParts>
Does anybody have any ideas as to what could be causing the issue when I deploy to the dev machine? The only other thing I can think of is that my local machine is Windows 7 and the dev machine is Windows Server 2008. Both are running SharePoint Foundation
It can not find the assembly referenced in the web part. The error you are seeing is actually the equivelant from this line of code.
Cannot import this Web Part.
What you need to do is verify the full class and assembly reference names in your .webpart definition file and update accordingly.
Unfortunately I can't tell you what it should be exactly because your project definition may be outputting the assembly with different info than your class defintion.

log4net console app not logging on publish

I have a console app using log4net (via Castle Windsor). Everything logs fine to the console when I debug, but when I publish and run the app, nothing is logged.
I have my log4net configuration in a separate file (log4net.config).
I'm thinking it's not finding the config file, but that's just a guess.
I'm a web dev and haven't deployed many console apps. Am I missing something?
Do I need to manually copy the log4net.config file to the exe directory?
I'm on VS2010.
app.config:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false"/>
</configSections>
<appSettings>
...
<add key="log4net.Internal.Debug" value="false"/>
</appSettings>
<startup>
<supportedRuntime version="v2.0.50727"/></startup>
<castle>
<components>
...
</components>
<facilities>
<facility id="loggingfacility" configfile="log4net.config" loggingapi="log4net" type="Castle.Facilities.Logging.LoggingFacility, Castle.Facilities.Logging"/>
</facilities>
</castle>
</configuration>
log4net.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<log4net>
<root>
<!-- Value of priority may be ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF -->
<priority value="ALL" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d: [%-5p] %m%n" />
</layout>
</appender>
<logger name="Castle">
<level value="INFO" />
</logger>
</log4net>
</configuration>
This is a wild guess, but have you marked "Build Action" of your log4net.config file as 'Content', and set it's property "Copy to Output directory" to "Copy always".
This way you don't have to copy file, and this file is considered as 'content' of the build output and will be included in your publish.

Resources