Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8449663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:46:21+00:00 2026-06-10T10:46:21+00:00

Problems with Silverlight 4 application. In this application every client session creates a separate

  • 0

Problems with Silverlight 4 application.
In this application every client session creates a separate process, which calls a DLL.

Communication with DLL is built as in the following callstack (for two functions: one working, another – not).

There are 2 functions in DLL (both work fine):

extern "C" BOOL __stdcall DocRunExternPageDividions(const char *docId, int num_form, int PageNum, int *Vcols, int **Vvalues, int *Hcols, int **Hvalues)
{
    LOG_START_FUNCTION
    BOOL res = 1;
    __try {
        res = DocRunExternPageDividions1(docId, num_form, PageNum, Vcols, Vvalues, Hcols, Hvalues);
    }
    __except(ExFilter(GetExceptionInformation()))
    {
        AfxThrowUserException();
    }
    LOG_STOP_FUNCTION
    return res;
}


extern "C" BOOL __stdcall DocRunExternPageBreakRects(const char *docId, int num_form, int PageNum)
{
    LOG_START_FUNCTION
        BOOL res = 1;
    __try {
        res = DocRunExternPageBreakRects1(docId, num_form, PageNum);
    }
    __except(ExFilter(GetExceptionInformation()))
    {
        AfxThrowUserException();
    }
    LOG_STOP_FUNCTION
        return res;
}

To call this functions server has two delegates:

private delegate void DocRunExternPageBreakRectsDelegate(string docId, int DocNum, int PageNum);

private delegate void DocRunExternPageDividionsDelegate(
    string docId, int DocNum, int PageNum, out int Vcols, out IntPtr VoutArray, out int Hcols,
    out IntPtr HoutArray);

… two delegate instances and corresponding functions:

    private DocRunExternPageBreakRectsDelegate DocRunExternPageBreakRectsD;
                DocRunExternPageBreakRectsD =
                Marshal.GetDelegateForFunctionPointer(ptrDocRunExternPageBreakRects,
                                                      typeof (DocRunExternPageBreakRectsDelegate)) as
                DocRunExternPageBreakRectsDelegate;

    private DocRunExternPageDividionsDelegate DocRunExternPageDividionsD;
                DocRunExternPageDividionsD =
                Marshal.GetDelegateForFunctionPointer(ptrDocRunExternPageDividionsD,
                                                      typeof (DocRunExternPageDividionsDelegate)) as
                DocRunExternPageDividionsDelegate;

    public void DocRunExternPageDividions(string docId, int DocNum, int PageNum, out int[] vert, out int[] horz) {
        IntPtr VoutArray, HoutArray;
        int vcols, hcols;
        DocRunExternPageDividionsD(docId, DocNum, PageNum, out vcols, out VoutArray, out hcols, out HoutArray);
        marshal(VoutArray, out vert, vcols);
        marshal(HoutArray, out horz, hcols);
    }

    public void DocRunExternPageBreakRects(string docId, int DocNum, int PageNum) {
        DocRunExternPageBreakRectsD(docId, DocNum, PageNum);
    }

Each of these functions is called here (server code):

    public bool PageBreakRects(string docId, int DocNum, int PageNum, out int[] vert, out int[] horz) {
        bool result;
        vert = null;
        horz = null;
        Program.WriteUserMessage("Called PageBreakRects(" + docId + ", " + DocNum + ", " + PageNum + ")");
        try {
            DocRunExternPageBreakRects(docId, DocNum, PageNum);
            DocRunExternPageDividions(docId, 0, PageNum, out vert, out horz);
            result = true;
        } catch (Exception ex) {}
        return result;
    }

    public bool GetPageDividions(string docID, int Id, int pageNumber, out int[] vert, out int[] horz) {
        bool result = false;
        vert = null;
        horz = null;
        try {
            DocRunExternPageDividions(docID, Id, pageNumber, out vert, out horz);
            result = true;
        } catch (Exception) {}
        return result;
    }

Each of them – are called here:

    public DocDividionsResult PageBreakRects(string docID, int DocNum, int pageNumber) {
        var result = new DocDividionsResult();
        int[] vert;
        int[] horz;
        result.Data = new List<object> { Program.DllWrapper.PageBreakRects(docID, DocNum, pageNumber, out vert, out horz) };
        result.Vert = vert;
        result.Horz = horz;
        return result; 
    }

    public DocDividionsResult GetPageDividions(string docID, int formId, int pageNumber) {
        var result = new DocDividionsResult();
        int[] vert;
        int[] horz;
        result.Data = new List<object>
                      {Program.DllWrapper.GetPageDividions(docID, formId, pageNumber, out vert, out horz)};
        result.Vert = vert;
        result.Horz = horz;
        return result;
    }

Then – within lambda-expressions:

    public bool GetPageDividions(string docID, int formId, int pageNumber, out int[] vert, out int[] horz) {
        bool result = false;
        int []localVert = null;
        int []localHorz = null;

        if (_wp != null) {
            if (Service<IWPCommunication>.Use(TestService =>
            {
                TestService.Test(UserId);
            },
            WPService =>
            {
                DocDividionsResult br = WPService.GetPageDividions(docID, formId, pageNumber);
                if (br != null && br.Data != null && br.Data.Length == 1)
                {
                    result = (bool)br.Data[0];
                    localVert = br.Vert;
                    localHorz = br.Horz;
                }
            }, Id, FS) == 0)
            {
        ...
                result = false;
            }
        }
        vert = localVert;
        horz = localHorz;
        return result;
    }

    public bool PageBreakRects(string docId, int DocNum, int PageNum) {
        bool result = false;
        if (_wp != null)
        {
            if (Service<IWPCommunication>.Use(TestService =>
            {
                TestService.Test(UserId);
            },
            WPService =>
            {
                DocDividionsResult br = WPService.PageBreakRects(docId, DocNum, PageNum);
                if (br != null && br.Data != null && br.Data.Length == 1) {
                    result = (bool)br.Data[0];
                }
            }, Id, FS) == 0)
            {
        ...
                result = false;
            }
        }
        return result;
    }

The “Use” function (used above):

    public static int Use(UseServiceDelegate<T> codeTest, UseServiceDelegate<T> codeBlock, string SessionId, FileStream fs, bool throwException) {
        IClientChannel texy = (IClientChannel)_testFactory.CreateChannel(new EndpointAddress("net.pipe://localhost/X2WPServiceUID" + SessionId));
        IClientChannel proxy = (IClientChannel)_channelFactory.CreateChannel(new EndpointAddress("net.pipe://localhost/X2WPServiceUID" + SessionId));
        int returnCode = 0;
        try {
            if (codeTest != null) {
                codeTest((T)texy);
                texy.Close();
            }
            returnCode = 1;
            if (codeBlock != null) {
                codeBlock((T)proxy);
                proxy.Close();
            }
            returnCode = 2;
        } catch(Exception e) {
            if (returnCode == 1 && throwException)
                throw e;
        } finally {
            if (returnCode == 0 && codeTest != null)
                texy.Abort();
            else if (returnCode == 1 && codeBlock != null)
                proxy.Abort();
        }
        return returnCode;
    }

Client communication is omitted as exception is raised on the server side.
GetPageDividions function works fine, bug PageBreakRects – not: the line
DocDividionsResult br = WPService.PageBreakRects(docId, DocNum, PageNum);
throws the following exception:

"The message with Action 'http://tempuri.org/IWPCommunication/PageBreakRects' 
cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher.
This may be because of either a contract mismatch (mismatched Actions between sender and receiver) 
or a binding/security mismatch between the sender and the receiver.  
Check that sender and receiver have the same contract and the same binding 
(including security requirements, e.g. Message, Transport, None)."

It is worse mentioning, that if in function PageBreakRects replace:
DocDividionsResult br = WPService.PageBreakRects(docId, DocNum, PageNum);
with
DocDividionsResult br = WPService.GetPageDividions(docID, formId, pageNumber);
then no exception is thrown.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:46:22+00:00Added an answer on June 10, 2026 at 10:46 am

    Not sure if you have started at the very beginning or not, but I expect that none of the code you posted is causing the error. That error means that you are having trouble calling your webservice from the client (silverlight) because there is an error in the system.serviceModel section in your web config. You can often fix it by just refreshing your service reference.

    Try running the app locally in visual studio and point the service reference to the service you installed on the server (right click on the service reference and select Configure Service reference then change the URl to correspond to the service location on your server). If you are already developing/testing in this configuration try right clicking on the service reference and select “Update Service Reference”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'me currently developing a silverlight application. In this application, I've an exception handler which
I'm facing some problems with my silverlight application. My application looks like an image
We've got a client who wants to use a SilverLight application hosted on our
I have a Silverlight application that I am trying to style. This style simply
I am using canvas in wp7 silverlight application. I am facing two problems. So
In my application (Silverlight client - server - SQL Server DB) with SQL Server
I'm experiencing two intermittent problems with Silverlight 3.0, running on Windows 7 with Visual
I'm using XmlSerializer. I've had no problems with it until now. I updated Silverlight
I have client-server application, where server side is Azure WCF service with data in
I am developing a silverlight 3 application using WCF RIA services. I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.