求解oob模式下的问题,csdn论坛就没满意回答过一次我的sl相关问题,给点希望吧
在浏览器下面一切正常,在OOB模式下就出错,调试出了出错位置,但不知道应该怎么修改才能使之浏览器和OOB模式都正常。
请问怎么解决
- C# code
public class ViewModelManager { private static Application app = Application.Current; public static void InjectViewModelsToResources() { Assembly executingAssembly = Assembly.GetCallingAssembly(); foreach (Type type in executingAssembly.GetTypes()) { var attributes = type.GetCustomAttributes(false); foreach (var attribute in attributes) { if (attribute is StaticResourceAttribute) { var obj = Activator.CreateInstance(type); 断点提示出错位置 if (!app.Resources.Contains(type.Name)) app.Resources.Add(type.Name, obj); } } } } public static T GetViewModelFromResources<T>() { var key = typeof(T).Name; if (app.Resources.Contains(key)) return (T)app.Resources[key]; else return default(T); } }错误提示:
- Assembly code
用户代码未处理 System.Reflection.TargetInvocationException Message=调用的目标发生了异常。 StackTrace: 位于 System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) 位于 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) 位于 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) 位于 System.Activator.CreateInstance(Type type, Boolean nonPublic) 位于 System.Activator.CreateInstance(Type type) 位于 RapidSL.UI.Core.ViewModelManager.InjectViewModelsToResources() 位于 RapidSL.UI.OutofBrowserMainPage..ctor() 位于 RapidSL.UI.App.Application_Startup(Object sender, StartupEventArgs e) 位于 MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args) 位于 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags) InnerException: System.ArgumentException Message=提供的 URI 方案“file”无效;应为“http”。参数名: via StackTrace: 位于 System.ServiceModel.Channels.TransportChannelFactory`1.ValidateScheme(Uri via) 位于 System.ServiceModel.Channels.HttpChannelFactory.ValidateCreateChannelParameters(EndpointAddress remoteAddress, Uri via) 位于 System.ServiceModel.Channels.HttpChannelFactory.OnCreateChannel(EndpointAddress remoteAddress, Uri via) 位于 System.ServiceModel.Channels.ChannelFactoryBase`1.InternalCreateChannel(EndpointAddress address, Uri via) 位于 System.ServiceModel.Channels.ChannelFactoryBase`1.CreateChannel(EndpointAddress address, Uri via) 位于 System.ServiceModel.Channels.ServiceChannelFactory.ServiceChannelFactoryOverRequest.CreateInnerChannelBinder(EndpointAddress to, Uri via) 位于 System.ServiceModel.Channels.ServiceChannelFactory.CreateServiceChannel(EndpointAddress address, Uri via) 位于 System.ServiceModel.Channels.ServiceChannelFactory.CreateChannel(Type channelType, EndpointAddress address, Uri via) 位于 System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via) 位于 System.ServiceModel.ChannelFactory`1.CreateChannel() 位于 System.ServiceModel.DomainServices.Client.WebDomainClient`1.BeginQueryCore(EntityQuery query, AsyncCallback callback, Object userState) 位于 System.ServiceModel.DomainServices.Client.DomainClient.BeginQuery(EntityQuery query, AsyncCallback callback, Object userState) 位于 System.ServiceModel.DomainServices.Client.DomainContext.Load(EntityQuery query, LoadBehavior loadBehavior, Action`1 callback, Object userState) 位于 System.ServiceModel.DomainServices.Client.DomainContext.Load[TEntity](EntityQuery`1 query) 位于 RapidSL.UI.ViewModels.LoginViewModel.Init() 位于 RapidSL.UI.Core.MyViewModelBase..ctor() 位于 RapidSL.UI.ViewModels.EditableViewModel..ctor() 位于 RapidSL.UI.ViewModels.LoginViewModel..ctor() InnerException:
[解决办法]
这样吧,你给出这样的代码出这样的错误任何人都不能给你答案,顶多给你几个方向去检查一下,不过看到最后的stacktrace,
InnerException: System.ArgumentException
Message=提供的 URI 方案“file”无效;应为“http”。
位于 RapidSL.UI.ViewModels.LoginViewModel.Init()
位于 RapidSL.UI.Core.MyViewModelBase..ctor()
位于 RapidSL.UI.ViewModels.EditableViewModel..ctor()
位于 RapidSL.UI.ViewModels.LoginViewModel..ctor()
这几个部分仔细研究一下,看看oob模式和web模式的区别,看看oob不支持什么东西,再综合你写的程序,分析一下原因,
另外看到InnerException的message,说明应该是你对本地文件操作的部分oob和web的支持不一样,这句Message=提供的 URI 方案“file”无效;应为“http”。