次のエラーが表示されます。
The type 'Drive_Service.DriveSessionsController', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
サービス名と名前空間が同じでない場合にこれがスローされる可能性があることは理解していますが、おそらく50回以上チェックしましたが、同じように見えます。なぜこのエラーが発生するのかわかりません。
Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="wsDualHttpBinding"/>
</protocolMapping>
<services>
<service name="Drive_Service.DriveSessionsController">
<endpoint address="DriveSessionsController" binding="wsDualHttpBinding" contract="Drive_Service.ISessionController"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:55534"/>
</baseAddresses>
</host>
</service>
<service name="Drive_Service.ServiceWithCallback">
<endpoint address="ServiceWithCallback" binding="wsDualHttpBinding" contract="Drive_Service.IServiceWithCallback"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:55534"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
SVC マークアップ
<%@ ServiceHost Language="C#" Debug="true" Service="Drive_Service.DriveSessionsController" CodeBehind="DriveSessionsController.svc.cs" %>
SVCコード
namespace Drive_Service
{
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]
public class DriveSessionsController : ISessionController
{
#region Fields
private Object syncRoot = new Object();
private Timer timer = new Timer();
#endregion
#region Properties
/// <summary>
/// Gets and sets the flag indicating to use the .NET 2 runtime in conjunction
/// with the assembly .NET runtime.
/// </summary>
public static bool LegacyV2RuntimeEnabledSuccessfully { get; private set; }
#endregion
#region Constructors
/// <summary>
/// Constructor.
/// </summary>
public DriveSessionsController()
{
ICLRRuntimeInfo clrRuntimeInfo = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID);
try
{
clrRuntimeInfo.BindAsLegacyV2Runtime();
LegacyV2RuntimeEnabledSuccessfully = true;
}
catch (COMException)
{
LegacyV2RuntimeEnabledSuccessfully = false;
}
timer.Elapsed += new ElapsedEventHandler(this.ProcessUpdate);
timer.Interval = 5000;
timer.Enabled = true;
timer.Start();
}
#endregion
#region Internal Members
/// <summary>
/// Interface to the common language runtime information.
/// </summary>
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("BD39D1D2-BA2F-486A-89B0-B4B0CB466891")]
private interface ICLRRuntimeInfo
{
void xGetVersionString();
void xGetRuntimeDirectory();
void xIsLoaded();
void xIsLoadable();
void xLoadErrorString();
void xLoadLibrary();
void xGetProcAddress();
void xGetInterface();
void xSetDefaultStartupFlags();
void xGetDefaultStartupFlags();
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void BindAsLegacyV2Runtime();
}
/// <summary>
/// Disconnect the client.
/// </summary>
/// <param name="sessionID">The session id.</param>
private void ClientDisconnect(string sessionID)
{
lock (syncRoot)
{
if (SessionManager.IsClientConnected(sessionID))
{
SessionManager.DeleteClient(sessionID);
}
}
}
/// <summary>
/// Generate the client data for the service.
/// </summary>
/// <returns></returns>
private ClientData GenerateClientData()
{
DataTranslator translator = new DataTranslator();
SystemData systemData = translator.GetSystemData;
ClientData data = new ClientData();
data.UpdatedData = new List<DataValue>();
data.DriveStatusExchange = DriveStatusExchange.ERROR;
foreach (DriveStatusExchange status in DriveStatusExchange.GetValues())
{
if (status.Value == systemData.Status.ToString())
{
data.DriveStatusExchange = status;
break;
}
}
data.UpdatedData.Add(new DataValue() { Symbol = data.DriveStatusExchange.Value, Value = 0 });
return data;
}
#endregion
#region External Members
/// <summary>
/// Executed when client is subscribed to notifications from server.
/// </summary>
/// <param name="clientGuid"></param>
public void SubscribeToNotifications(string clientGuid)
{
ISessionCallbackContract ch = OperationContext.Current.GetCallbackChannel<ISessionCallbackContract>();
lock (syncRoot)
{
SessionManager.BrowserValue = clientGuid;
if (!SessionManager.IsClientConnected(clientGuid))
{
SessionManager.AddCallbackChannel(clientGuid, ch);
OperationContext.Current.Channel.Closing += new EventHandler(Channel_Closing);
OperationContext.Current.Channel.Faulted += new EventHandler(Channel_Faulted);
}
}
}
/// <summary>
/// Executed when client is unsubscribed to notifications from server.
/// </summary>
public void UnsubscribeToNotifications()
{
ClientDisconnect(OperationContext.Current.Channel.SessionId);
}
#endregion
#region Events
/// <summary>
/// Process updating for each client.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ProcessUpdate(object sender, EventArgs e)
{
ClientData data = GenerateClientData();
if (SessionManager.GetCallbackChannels().Count() > 0)
{
lock (syncRoot)
{
IEnumerable<ISessionCallbackContract> allChannels = SessionManager.GetCallbackChannels();
allChannels.ToList().ForEach(c => c.SendNotificationToClients(data));
}
}
}
/// <summary>
/// Handle closing the channel.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Channel_Closing(object sender, EventArgs e)
{
IContextChannel channel = (IContextChannel)sender;
ClientDisconnect(channel.SessionId);
}
/// <summary>
/// Handle a faulted channel.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Channel_Faulted(object sender, EventArgs e)
{
IContextChannel channel = (IContextChannel)sender;
ClientDisconnect(channel.SessionId);
}
#endregion
}
}
誰かが私が見逃しているものを見ていますか?
乾杯。