Reputation: 781
I have one project which has RIAService with entity framework that is referenced to my Silvelright project. so when i build project that build RIA Service project's DLL and put that in Bin/Debug folder of Silverlight project.
Domain service function is like below
[EnableClientAccess()]
public partial class MyClassDomainService : LinqToEntitiesDomainService<MyDatabaseEntities>
{
[Invoke]
public void MyFunction(int Para1, string Para2, int Para3, string Para4)
{
//mycode
}
}
Now i am build this porject and copy this RIAService.dll and other require DLLs to my another project is window service project.
Now in window service i am creating object of this Domain service as like below in timerQlinkRequest_Elapsed() function.
private void timerQ_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
MyClassDomainContext objcontext = new MyClassDomainContext();
objcontext.MyFunction(1, "ADD", 1234, "Vehicle");
}
catch (Exception ex)
{
LogMessage("Error : StackTrace : " + ex.StackTrace);
}
}
After installing and Start window service i get below error in ex.stackTrace in log filem as below
Error : StackTrace : at MS.Internal.JoltHelper.get_Context()
at MS.Internal.XcpImports.Application_GetCurrent(IntPtr& pApp)
at System.Windows.Application.get_Current()
at System.ServiceModel.DomainServices.Client.WebDomainClient`1.ComposeAbsoluteServiceUri()
at System.ServiceModel.DomainServices.Client.WebDomainClient`1..ctor(Uri serviceUri)
at RIAService.Web.Service.QLink.MyClassDomainContext..ctor()
at MywindowService.MyService1.timerQ_Elapsed(Object sender, ElapsedEventArgs e)
so my main confusion is, can i do like this? if yes then where i go wrong?
please help me.
waiting for reply.
Upvotes: 0
Views: 292
Reputation: 781
i get solution in other way,
in my project.Web (ASP.NET project) i create a simple WCF application that call my function of WCF RIA Service.
And in window service solution I add service reference of that WCF service and calling that WCF function and complete my task.
@duluca thanks fro the reply.
Upvotes: 0
Reputation: 7323
You shouldn't be doing what you're trying to do. WCF RIA was created to bridge the gap between specific implementations of server and client applications. When you build your project, there's all kinds of code-generation going on that ties the client to an implementation on the server.
Now, what you CAN do here is:
I recommend the 1st option, if you're going for Edit capabilities. But 2nd option should work relatively painlessly for read-only data. But then again for that I'd recommend exposing an O-Data endpoint, which is very easy to do in WCF RIA.
Upvotes: 1