VB and Sync Framework 4.0
-
2011年8月19日 17:23
I have been going through the SDK examples for creating a Sync Service and when I do the example in C# all is well. When I try to do the exact same steps in VB I get the following error when running the service. Any ideas?
The type 'DefaultScope.DefaultScopeSyncService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The type 'DefaultScope.DefaultScopeSyncService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The type 'DefaultScope.DefaultScopeSyncService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.] System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +52042 System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440 System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +615 [ServiceActivationException: The service '/DefaultScopeSyncService.svc' cannot be activated due to an exception during compilation. The exception message is: The type 'DefaultScope.DefaultScopeSyncService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..] System.Runtime.AsyncResult.End(IAsyncResult result) +687598 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234 System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +355 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
すべての返信
-
2011年8月26日 0:57モデレータhave you checked the config entries to match your service ?
-
2011年9月1日 13:31Thanks for the response. I'm not sure what you mean. Could you be more specific. Any help is appreciated, thanks again.
-
2011年9月2日 1:38モデレータopen up your svc file and check the service attribute, then check if your config file entries for the service actually matches it.
-
2011年9月2日 11:51thanks for your reply. I should elaborate that I'm not even trying to connect to the service yet. It won't even run, providing the default meta data screen in the browswer. I double check all references of the service and they all seem to match. As I said before in C# the exact same steps work fine, so I'm at a bit of a loss. Thanks for your help, anything else would be appreciated.
-
2011年10月13日 3:05Have you been able to solve this issue?? I am having the same problem.
-
2012年6月5日 19:08Same here. Any word from MS?
Alon
-
2012年6月6日 0:05モデレータcan you post your web.config file and svc file here?
-
2012年6月6日 18:51
Hi JuneT, here are the files:
<?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <system.web> <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" /> </system.web> </configuration>
Option Strict Off Option Explicit On Namespace DefaultScope #Region "SyncService: Configuration and setup" Public Class DefaultScopeSyncService Inherits Microsoft.Synchronization.Services.SyncService(Of DefaultScopeOfflineEntities) Public Shared Sub InitializeService(ByVal config As Microsoft.Synchronization.Services.ISyncServiceConfiguration) ' TODO: MUST set these values config.ServerConnectionString = "Data Source=ALONVAIO\SQLEXPRESS;Initial Catalog=listDb;Integrated Security=true" config.SetEnableScope("DefaultScope") ' ' 'TODO: Optional. config.SetDefaultSyncSerializationFormat(Microsoft.Synchronization.Services.SyncSerializationFormat.ODataJson) config.SetConflictResolutionPolicy(Microsoft.Synchronization.Services.ConflictResolutionPolicy.ServerWins) ' configure filter parameters used by the service config.AddFilterParameterConfiguration("userid", "User", "@ID", GetType(System.Guid)) config.AddFilterParameterConfiguration("userid", "Item", "@UserID", GetType(System.Guid)) config.AddFilterParameterConfiguration("userid", "List", "@UserID", GetType(System.Guid)) config.AddFilterParameterConfiguration("userid", "TagItemMapping", "@UserID", GetType(System.Guid)) ' enable Diagnostic Dashboard feature for the service config.EnableDiagnosticPage = True ' enable verbose errors config.UseVerboseErrors = True End Sub End Class #End Region End Namespace
Option Strict Off Option Explicit On Namespace DefaultScope Public Class DefaultScopeOfflineEntityBase Inherits Object Implements Microsoft.Synchronization.Services.IOfflineEntity Private _serviceMetadata As Microsoft.Synchronization.Services.OfflineEntityMetadata Public Sub New() MyBase.New ServiceMetadata = New Microsoft.Synchronization.Services.OfflineEntityMetadata End Sub Public Overridable Property ServiceMetadata() As Microsoft.Synchronization.Services.OfflineEntityMetadata Implements Microsoft.Synchronization.Services.IOfflineEntity.ServiceMetadata Get Return _serviceMetadata End Get Set If (value Is Nothing) Then Throw New System.ArgumentNullException("value") End If _serviceMetadata = value End Set End Property End Class <Microsoft.Synchronization.Services.SyncEntityTypeAttribute(TableGlobalName:="Tag", TableLocalName:="[Tag]", KeyFields:="ID")> _ Partial Public Class Tag Inherits DefaultScopeOfflineEntityBase Private _ID As Integer Private _Name As String Public Property ID() As Integer Get Return _ID End Get Set _ID = value End Set End Property Public Property Name() As String Get Return _Name End Get Set _Name = value End Set End Property End Class <Microsoft.Synchronization.Services.SyncEntityTypeAttribute(TableGlobalName:="Priority", TableLocalName:="[Priority]", KeyFields:="ID")> _ Partial Public Class Priority Inherits DefaultScopeOfflineEntityBase Private _ID As Integer Private _Name As String Public Property ID() As Integer Get Return _ID End Get Set _ID = value End Set End Property Public Property Name() As String Get Return _Name End Get Set _Name = value End Set End Property End Class <Microsoft.Synchronization.Services.SyncEntityTypeAttribute(TableGlobalName:="Status", TableLocalName:="[Status]", KeyFields:="ID")> _ Partial Public Class Status Inherits DefaultScopeOfflineEntityBase Private _ID As Integer Private _Name As String Public Property ID() As Integer Get Return _ID End Get Set _ID = value End Set End Property Public Property Name() As String Get Return _Name End Get Set _Name = value End Set End Property End Class <Microsoft.Synchronization.Services.SyncEntityTypeAttribute(TableGlobalName:="User", TableLocalName:="[User]", KeyFields:="ID")> _ Partial Public Class User Inherits DefaultScopeOfflineEntityBase Private _ID As System.Guid Private _Name As String Public Property ID() As System.Guid Get Return _ID End Get Set _ID = value End Set End Property Public Property Name() As String Get Return _Name End Get Set _Name = value End Set End Property End Class <Microsoft.Synchronization.Services.SyncEntityTypeAttribute(TableGlobalName:="List", TableLocalName:="[List]", KeyFields:="ID")> _ Partial Public Class List Inherits DefaultScopeOfflineEntityBase Private _ID As System.Guid Private _Name As String Private _Description As String Private _UserID As System.Guid Private _CreatedDate As Date Public Property ID() As System.Guid Get Return _ID End Get Set _ID = value End Set End Property Public Property Name() As String Get Return _Name End Get Set _Name = value End Set End Property <Microsoft.Synchronization.Services.SyncEntityPropertyIsNullableAttribute()> _ Public Property Description() As String Get Return _Description End Get Set _Description = value End Set End Property Public Property UserID() As System.Guid Get Return _UserID End Get Set _UserID = value End Set End Property Public Property CreatedDate() As Date Get Return _CreatedDate End Get Set _CreatedDate = value End Set End Property End Class <Microsoft.Synchronization.Services.SyncEntityTypeAttribute(TableGlobalName:="Item", TableLocalName:="[Item]", KeyFields:="ID")> _ Partial Public Class Item Inherits DefaultScopeOfflineEntityBase Private _ID As System.Guid Private _ListID As System.Guid Private _UserID As System.Guid Private _Name As String Private _Description As String Private _Priority As System.Nullable(Of Integer) Private _Status As System.Nullable(Of Integer) Private _StartDate As System.Nullable(Of Date) Private _EndDate As System.Nullable(Of Date) Public Property ID() As System.Guid Get Return _ID End Get Set _ID = value End Set End Property Public Property ListID() As System.Guid Get Return _ListID End Get Set _ListID = value End Set End Property Public Property UserID() As System.Guid Get Return _UserID End Get Set _UserID = value End Set End Property Public Property Name() As String Get Return _Name End Get Set _Name = value End Set End Property <Microsoft.Synchronization.Services.SyncEntityPropertyIsNullableAttribute()> _ Public Property Description() As String Get Return _Description End Get Set _Description = value End Set End Property <Microsoft.Synchronization.Services.SyncEntityPropertyIsNullableAttribute()> _ Public Property Priority() As System.Nullable(Of Integer) Get Return _Priority End Get Set _Priority = value End Set End Property <Microsoft.Synchronization.Services.SyncEntityPropertyIsNullableAttribute()> _ Public Property Status() As System.Nullable(Of Integer) Get Return _Status End Get Set _Status = value End Set End Property <Microsoft.Synchronization.Services.SyncEntityPropertyIsNullableAttribute()> _ Public Property StartDate() As System.Nullable(Of Date) Get Return _StartDate End Get Set _StartDate = value End Set End Property <Microsoft.Synchronization.Services.SyncEntityPropertyIsNullableAttribute()> _ Public Property EndDate() As System.Nullable(Of Date) Get Return _EndDate End Get Set _EndDate = value End Set End Property End Class <Microsoft.Synchronization.Services.SyncEntityTypeAttribute(TableGlobalName:="TagItemMapping", TableLocalName:="[TagItemMapping]", KeyFields:="TagID,ItemID,UserID")> _ Partial Public Class TagItemMapping Inherits DefaultScopeOfflineEntityBase Private _TagID As Integer Private _ItemID As System.Guid Private _UserID As System.Guid Public Property TagID() As Integer Get Return _TagID End Get Set _TagID = value End Set End Property Public Property ItemID() As System.Guid Get Return _ItemID End Get Set _ItemID = value End Set End Property Public Property UserID() As System.Guid Get Return _UserID End Get Set _UserID = value End Set End Property End Class <Microsoft.Synchronization.Services.SyncScopeAttribute()> _ Public Class DefaultScopeOfflineEntities Private _Tags As System.Collections.Generic.ICollection(Of Tag) Private _Prioritys As System.Collections.Generic.ICollection(Of Priority) Private _Statuss As System.Collections.Generic.ICollection(Of Status) Private _Users As System.Collections.Generic.ICollection(Of User) Private _Lists As System.Collections.Generic.ICollection(Of List) Private _Items As System.Collections.Generic.ICollection(Of Item) Private _TagItemMappings As System.Collections.Generic.ICollection(Of TagItemMapping) End Class End Namespace
Thanks.
Alon
-
2012年6月6日 23:49モデレータi meant the mark up for the file with extension .svc
-
2012年6月6日 23:55I'm sorry, but what is the 'mark up' for a file?
Alon
-
2012年6月7日 1:32モデレータ
just open the svc file... you can right click on it in VS or open it in notepad
-
2012年6月7日 13:31
Is this what you meant?
<%@ ServiceHost Language="vb" Service="DefaultScope.DefaultScopeSyncService" CodeBehind="DefaultScopeSyncService.svc.vb" Factory="Microsoft.Synchronization.Services.SyncServiceHostFactory, Microsoft.Synchronization.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 " %>
Alon
-
2012年6月8日 0:04モデレータ
try this, change the Version=4.0.0.0 to Version=1.0.0.0 and take out the PublicKeyToken entry...
this has been posted here before but i cant find the thread. i remember having this same issue before...
- 回答の候補に設定 Alon R 2012年7月2日 18:42
-
2012年6月8日 13:32
Yep, now it is locading, thank you, JuneT.
The only thing is that with the service (according to the walkthrough), after clicking the Sync button, the button and the grid disappear and im getting a blank page. Any idea?
Alon
- 編集済み Alon R 2012年7月2日 18:42 typo
-
2012年6月9日 4:10モデレータ
have you checked the the service is really working?
try hitting this url: http://<host>/<servicename>.svc/$diag
you may also enabled detailed logging by setting this on the initializeservice
config.EnableDiagnosticPage = true;
if the service is ok, use fiddler to sniff out the traffice between your client and server to get a more detailed error...
-
2012年6月22日 20:10
Hi,
Just came back to this project... Answering the above, yes, the service is working. I have deserted the VB and moved back to the C#, at least for the service side.
Anyway, new error popped now -
I have made a new service, connected to my sample DB and now I'm getting this error when starting the service (both in C# and VB):
Could not load file or assembly 'Microsoft.Synchronization.Services, Version=1.0.0.0, Culture=neutral' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The markup is
<%@ ServiceHost Language="cs" Service="DefaultScope.DefaultScopeSyncService" CodeBehind="DefaultScopeSyncService.svc.cs"
Factory="Microsoft.Synchronization.Services.SyncServiceHostFactory, Microsoft.Synchronization.Services, Version=1.0.0.0, Culture=neutral" %>
I have tried also changing it to 'Version=4.0.0.0' with no difference.
The dll itself is version 4.0
(The ListDB sample works fine on my machine)
Thanks.
-
2012年6月25日 1:38モデレータhave you checked that you have sync framework installed on the machine?
-
2012年6月25日 13:55Are you serious? Well, I guess you had to ask. As I wrote, all is working with C# and the original sample of the listdb. So, yes, the answer is that all is installed.
-
2012年6月26日 1:24モデレータ
you mentioned you have the sample working on you your local machine so am assuming you are encountering the error in another machine and you mentioned its not working for both c# and vb.
check the target platform of your app if it matches the platform of sync fx you installed. e.g., x86 for x86 sync fx
-
2012年6月26日 18:23
Hi JuneT, thanks for bearing with me this puzzle...
All my tests are done on a Win7 ultimate x64 fully updated with VS2010 Professional. The Sync FW installed according to x64 instructions (loading the x86 dll in addition, etc.)
Both projects - the original sample and my test are defined in the project's properties -> Build -> Platform target as 'Any CPU'.
-
2012年6月26日 23:57モデレータ
try changing from "Any CPU" to match the sync fx you have installed.
if you're hosting the service in IIS, look up in the documentation for some configuration that needs to be done.
-
2012年6月27日 14:49
When targeting x86, I'm getting the same error:
Could not load file or assembly 'Microsoft.Synchronization.Services, Version=1.0.0.0, Culture=neutral' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
When targeting x64, I'm getting this one:
Could not load file or assembly 'P8SyncService' or one of its dependencies. An attempt was made to load a program with an incorrect format.
On all my tests (with the original example and the one I tried to pull), I'm using the VS2010 hosting.
-
2012年6月27日 15:07
Ditto Alon R.
I've having the difficulty as you with this using VB.Net
Windows 7 Pro OS 64bit
Sync 2.1 + 4.0 CTP + redistributables to run in VS2010
Just following starter tutorial
http://blog.dotnetstudio.nl/index.php/2011/01/21/using-the-sync-framework-on-windows-phone-7/
And trying to test the sync service prior to moving on to phone app part. And I've getting same errors. Have tried what JuneT suggested above but no joy, same errors as you are reporting.
-
2012年6月28日 1:56モデレータ
can you post a sample project where i could download and test?
i just tested creating a sample project adding the files generated by the toolkit's utility and everything works fine.
Sync Framework Toolkit (not the CTP), VS 2010 SP1, Sync Fx 2.1, windows 7 64bit
-
2012年6月28日 16:30
you can download from here a 7z file contains:
1. service project
2. DB script (very simple - 4 tables)
3. the Sync config file
Thank you.
-
2012年6月29日 10:37モデレータit would help if you can upload it simple zip file not requiring us to use another utility just to unzip it...
-
2012年6月29日 13:44
Here it is again as zip.
Sorry for that, you should try 7z - its free (for all) and by far better (higher compress rate) than any other compression tool, including full support in all of them.
-
2012年7月2日 10:58
Hi JuneT,
Any luck figuring out Alon R's problem? Looking at the C# samples, the service launches in the browser without issue on my machine.
BUT if I build a new blank web application in vb or c#
and use the SyncFramework Service Utilities to generate the logic (C:\Program Files (x86)\Microsoft SDKs\Microsoft Sync Framework\4.0\bin - these utilities )
and add reference to C:\Program Files (x86)\Microsoft SDKs\Microsoft Sync Framework\4.0\Server\Microsoft.Synchronization.Services.dll
I get different errors. In both cases the Service Markup is
<% @ ServiceHost Language="cs" Service="DefaultScope.DefaultScopeSyncService" CodeBehind="DefaultScopeSyncService.svc.cs" Factory="Microsoft.Synchronization.Services.SyncServiceHostFactory, Microsoft.Synchronization.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 " %>
vb
The type 'DefaultScope.DefaultScopeSyncService', provided as the Service attribute value in the ServiceHost directive could not be found.
c#
Could not load file or assembly 'Microsoft.Synchronization.Services, Version=1.0.0.0' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I've compared the c# code to the sample its identical along so its really puzzling why it renders this error. I know I must be missing something very fundamental here but I just can't seem to find it. I've tried setting the version reference for the Synchronization.Services.dll to 1.0.0.0 but this results in manifest mismatch error.
-
2012年7月2日 11:29モデレータ
Alon,
I opened your project and simply replaced the references for Microsoft.Synchronization.Services to reference the assembly from the Sync Framwork Toolkit and it all works fine.
I suggest you all download the Sync Framework Toolkit from here:http://code.msdn.microsoft.com/Sync-Framework-Toolkit-4dc10f0e
Stop using the CTP bits, the final release of the Sync Framework v4 CTP is the Sync Framework Toolkit.
- 回答の候補に設定 Alon R 2012年7月2日 18:41
-
2012年7月2日 15:55
Hi JuneT,
Would you recommend uninstalling the Sync Framework 4.0 CTP altogether?
I took your advice, downloaded the toolkit, built the solution and followed the chm for creating a sync service.
C# web application following all steps to the letter and...
The type 'DefaultScope.DefaultScopeSyncService', provided as the Service attribute value in the ServiceHost directive could not be found.
when I get to step 8 of walkthrough on setting up a sync service.....
-
2012年7月2日 18:41
Hi June, it is now working as expected, at least in my preliminary tests. Thank you.
I assume you have some connection with the MS sync team... They really must improve their site - the first entry on the site's "Featured Resources" is the 2010 CTP... the first "Top Download" is the 2010 CTP... It is very hard to find actual material on the Sync, apart from these forumes (where you are giving 'A' grade support). It actually looks like a deserted platform...
Even on the forum's entry - the last update is of almost a year ago and is talking mainly on the CTP, mentioning the toolkit only as a code sample for 2.1...
Totally unclear and not potential user friendly.
Thanks again.
-
2012年7月3日 10:07
Hi JuneT,
Is this toolkit "ready" for use? My employer is looking to deploy LOB applications across a range of smart devices and I need to be sure that synchronisation with our backend SQL server dbs can be fulfilled in a stable manner using a suitable framework.
Given than I've still struggling to get the sync even initialised, it does make me nervous of what other hurdles I might face and what type of support is available to deal with this.
Is this toolkit being used heavily in commercial capacity?? Or should I look for a different solution?
-
2012年7月3日 10:25モデレータ
i can't speak for its adoption. the only indication would be the number of downloads of the toolkit.
the toolkit is provided in source as well, just check the corresponding licenses as the server and client components has different licensing (MSPL and Apache).
personally, i havent seen any other viable framework options out there.
-
2012年7月3日 23:05@WizzWozza -
Is this toolkit being used heavily in commercial capacity?? Or should I look for a different solution?
Yes, that is exactly the issue. There are no alternatives, as much as it sounds crazy. None that I know of anyway. If you know of anything, please let us all know. Thanks.