求解oob模式下的问题,csdn论坛就没满意回答过一次我的sl相关问题,给点希望吧
在浏览器下面一切正常,在OOB模式下就出错,调试出了出错位置,但不知道应该怎么修改才能使之浏览器和OOB模式都正常。
请问怎么解决
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); } }
用户代码未处理 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: