Hi
I just wanted to ask as I had taken quite a bit of time last night to
get this working, and didn't really manage, so wanted to check I was
going along the right direction with this, as Ive since read a few
posts saying running under medium trust isnt an issue and it should
work fine.
The error I am getting is-
Exception Details: System.Security.SecurityException: That assembly
does not allow partially trusted callers.
[SecurityException: That assembly does not allow partially trusted
callers.]
Blog.Core.InversionOfControl.IoC..cctor() in C:\Users\rob\Documents
\Visual Studio 2008\Projects\Blog\Blog.Core\InversionOfControl\IoC.cs:
58
And the code for that class is-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.Windsor;
using System.IO;
using System.Configuration;
using Blog.Core.DataAccess;
using Blog.Common.DesignByContract;
using Blog.Core.ServiceInterfaces;
namespace Blog.Core.InversionOfControl
{
public static class IoC
{
#region Members
/// <summary>
/// Windsor container instance
/// </summary>
private static IWindsorContainer _container = null;
#endregion
#region Construction
/// <summary>
/// Statically initialises the <see cref="IoC"/> class.
/// Reads castle config file to initialise the container
/// </summary>
static IoC()
{
string filePath =
ConfigurationManager.AppSettings["CASTLE_CONFIG_FILE"];
if (filePath != null && filePath != "")
{
Require.Is.NotBlank(filePath, "Castle config file not
specified in app/web config.\r\nPlease add appSettings element with
CASTLE_CONFIG_FILE key");
//will resolve filePath if running in web context
filePath = filePath.Replace("currentDirectory//",
AppDomain.CurrentDomain.BaseDirectory);
//will resolve the filePath if running in test context
filePath = filePath.Replace("currentDirectory\\",
AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug", ""));
//filePath = AppDomain.CurrentDomain.BaseDirectory;
if (File.Exists(filePath))
{
Require.Is.True(File.Exists(filePath),
"Specified file does not exist: " + filePath);
_container = new WindsorContainer(filePath);
}
else
{
throw new Exception("filePath does not exist");
}
}
}
#endregion
#region Public Static Methods
/// <summary>
/// Resolves an instance via the windsor container.
/// </summary>
/// <typeparam name="T">The type of the instance</typeparam>
/// <returns>New or existing instance</returns>
public static T Resolve<T>()
{
object instance = _container.Resolve(typeof(T));
return instance != null ? (T)instance : default(T);
}
/// <summary>
/// Gets a DAO from the windsor container.
/// </summary>
/// <typeparam name="T">The type of the DAO to return</
typeparam>
/// <returns>A DAO object of the given DAO type</returns>
public static T GetDao<T>()
{
IDaoFactory daoFactory = Resolve<IDaoFactory>();
Require.Is.NotNull(daoFactory,
"DaoFactory instance can not be retreived from dat IoC
container!");
return daoFactory.GetDao<T>();
}
#endregion
}
}
I'm not sure why the error has the full file path from my dev machine,
as this is the error on my web space, it works fine locally
Thanks for any help
Regards
Rob
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.