Quantcast
Channel: VBForums - WPF, WCF, WF
Viewing all 277 articles
Browse latest View live

Going back to WCF, using SSL

$
0
0
Hey,
Code:

  <security mode ="TransportWithMessageCredential">
          <message clientCredentialType="UserName" />

I am trying to work out an ssl - certificate site. This time the company has some real bought certificates so i am good to go this field.
What i want to ask is about the above code. I am thinking of implementing TransportWithMessageCredential with clientCredentialType="UserName" so already set security and no custom user-pass security level. I have seen tons of samples and to my surprise, not many will mention how the client will set the username pass security up. After downloading a MS sample and searching through hundreds of directories (actually i search for TransportWithMessageCredential with a tool) i found a "working sample" it used system.servicemodel.description.clientcredentials to pass fake creds (i will fix that) and it continues normally.
2 things here
1)I've read that client creds only needed as "fakes" for the aforementioned WCF service. Regardless on if i will use the creds correctly afterwards, is this the "basic" behavior?
2)I get to a point that:
Code:


  client.ClientCredentials.UserName.UserName = username
            client.ClientCredentials.UserName.Password = password.ToString()

            ' Call the GetCallerIdentity service operation
            Console.WriteLine(client.GetCallerIdentity())

GetCallerIdentity will produce the following issue:
"An error occurred while making the HTTP request to https://localhost/servicemodelsamples/service.svc. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server."

Is this an issue with the "fake" cert MS sample use or something else?
and
Code:

Public Function GetCallerIdentity() As String Implements ICalculator.GetCallerIdentity

            ' use ServiceSecurityContext.WindowsIdentity to get the name of the caller
            Return ServiceSecurityContext.Current.WindowsIdentity.Name

        End Function

Thanks.

[RESOLVED] Going back to WCF, using SSL

$
0
0
Hey,
Code:

  <security mode ="TransportWithMessageCredential">
          <message clientCredentialType="UserName" />

I am trying to work out an ssl - certificate site. This time the company has some real bought certificates so i am good to go this field.
What i want to ask is about the above code. I am thinking of implementing TransportWithMessageCredential with clientCredentialType="UserName" so already set security and no custom user-pass security level. I have seen tons of samples and to my surprise, not many will mention how the client will set the username pass security up. After downloading a MS sample and searching through hundreds of directories (actually i search for TransportWithMessageCredential with a tool) i found a "working sample" it used system.servicemodel.description.clientcredentials to pass fake creds (i will fix that) and it continues normally.
2 things here
1)I've read that client creds only needed as "fakes" for the aforementioned WCF service. Regardless on if i will use the creds correctly afterwards, is this the "basic" behavior?
2)I get to a point that:
Code:


  client.ClientCredentials.UserName.UserName = username
            client.ClientCredentials.UserName.Password = password.ToString()

            ' Call the GetCallerIdentity service operation
            Console.WriteLine(client.GetCallerIdentity())

GetCallerIdentity will produce the following issue:
"An error occurred while making the HTTP request to https://localhost/servicemodelsamples/service.svc. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server."

Is this an issue with the "fake" cert MS sample use or something else?
and
Code:

Public Function GetCallerIdentity() As String Implements ICalculator.GetCallerIdentity

            ' use ServiceSecurityContext.WindowsIdentity to get the name of the caller
            Return ServiceSecurityContext.Current.WindowsIdentity.Name

        End Function

Thanks.

https custom validation will still use ssl?

$
0
0
Hi.

I am creating a custom validation, meaning something like:
Code:

<basicHttpBinding>
        <binding name="defaultBasicHttpBinding">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceCredentials>
            <userNameAuthentication
              userNamePasswordValidationMode="Custom"
              customUserNamePasswordValidatorType="VSAPIService.MyUserNamePasswordValidator, VSAPIService"/>

So on the server side i am expecting the user to pass creds and i am validating like:
Code:

Public Overrides Sub Validate(userName As String, password As String)
        ' Credential validation logic
        '' if error
        '' Throw New HttpRequestValidationException
        Return  ' Accept anything
    End Sub

My question is if this is still a valid SSL https way. Meaning that it has all the https benefits and the data is passed in a secured manner.

Also in the future i may create a restfull way so i can use Json and Ajax calls. Will this validation be available as an option?

Thanks.

[RESOLVED] Unable to cast object of type 'System.Collections.Generic.List`1[System.String]' to t

$
0
0
Unable to cast object of type 'System.Collections.Generic.List`1[System.String]' to type 'WindowsApplication1.ServiceReferenceVSAPI.ArrayOfString'.
What is going on here? I cannot find a simple viable solution on Google.

Here is my WCF class:
Code:

Namespace MyTypes
    <DataContract(), KnownType(GetType(List(Of String))), XmlSerializerFormat()>
    <Serializable()>
    Public Class setorder
        <DataMember()>
        Public Property LoyaltyUserName() As String
            Get
                Return m_LoyaltyUserName
            End Get

            Set(value As String)
                m_LoyaltyUserName = value
            End Set
        End Property
        <DataMember()>
        Private m_LoyaltyUserName As String
        <DataMember()>
        Public Property LoyaltyPassword() As String
            Get
                Return m_LoyaltyPassword
            End Get
            Set(value As String)
                m_LoyaltyPassword = value
            End Set
        End Property
        <DataMember()>
        Private m_LoyaltyPassword As String

        <DataMember()>
        Public Property seats As List(Of String)
            Get
                Return m_seats
            End Get
            Set(value As List(Of String))
                m_seats = value
            End Set
        End Property
        <DataMember()>
        Private m_seats As List(Of String)
    End Class
End Namespace

here is the client code:
Code:

Dim vsetorder As New ServiceReferenceVSAPI.setorder       
        vsetorder.LoyaltyPassword = "asd"
        vsetorder.LoyaltyUserName = "g"
        Dim seats As New List(Of String)
        seats.Add("3")



        vsetorder.seats = seats

And i get the error on the vsetorder.seats = seats line.

I have tried every single model change on the wcf service (i thing system.collection.generic list is the most proper?) i have added and remove xml serialization features

alover and nothing works?

Any help?

P.S. I could care less if i use a list of or an arraylist but nothing works

[RESOLVED] WCF Datacontract element visible in client, but not in service itself

$
0
0
i've got this data contract
Code:

    [DataContract]
    public class SvcEuroCall
    {
        [DataMember]
        public Guid RequestID{get{return new Guid();}}
        [DataMember]
        public string OrderID { get; set; }
        [DataMember]
        public string status { get; set; }
        [DataMember]
        public string shipment { get; set; }
        [DataMember]
        public string pallet { get; set; }
        [DataMember]
        public string parcelid { get; set; }
        [DataMember]
        public string CC { get; set; }
        [DataMember]
        public string countryname { get; set; }
        [DataMember]
        SvcEuroOrderItem[] OrderItems { get; set; }
   
   
    }


    [DataContract]
    public class SvcEuroOrderItem
    {
        [DataMember]
        public string SKU { get; set; }
        [DataMember]
        public int Qty { get; set; }
        [DataMember]
        public string palletID { get; set; }
        [DataMember]
        public string MasterShipmentID { get; set; }


    }

in the client project i can see the SvcEuroCall.orderitems[] as an array i can add things to, but when i pass the object back to the service the service refuses to see the orderitems of the object.

for the life of me i cant figure out why?? why oh why must it be such a bear, this should NOT be this hard.

REST WCF , how to consume it and return object types

$
0
0
hi

I have my service contract below and implementation in other calls . Anyways , in the browser it's working find but when I try it in Windows Application it errors out . How can i use XML deserializer to get result out of both methods .

Code:


 [ServiceContract]
    public interface ISer
    {

        [OperationContract(Name = "SayHi")]
        [WebInvoke(Method = "GET", UriTemplate = "SayHi/{Name}")]
        string SayHi(string Name);



        [WebGet(BodyStyle = WebMessageBodyStyle.Wrapped,UriTemplate="/getEmployee")]
        Employee getEmployee();
    }



    [DataContract]
    public class Employee
    {
        [DataMember]
        public int EmployeeId { get; set; }


        [DataMember]
        public string Name { get; set; }
   
    }

Getting correct values from class but cannot check breakpoint

$
0
0
Hi. I have this class that default to a connection string.
Code:

#Region "connectionstrings"
Public NotInheritable Class GlobalConnections
    Private Sub New()   
    End Sub
    Shared Sub New()     
        Try
            strconVrExternal = ConfigurationManager.ConnectionStrings("DBConnectionString").ToString()
        Catch ex As Exception
            ' This should be checked if we are not getting a db connection and we see that the connection is set and called correctly.
        End Try
    End Sub

    Public Shared Property strconVrExternal() As String
        Get
            Return m_strconVrExternal
        End Get
        Set(value As String)
            m_strconVrExternal = value
        End Set
    End Property
    Private Shared m_strconVrExternal As String
    Public Shared Sub Setstrcon(newString As String)
        strconVrExternal = newString
    End Sub
End Class

Everything works fine but i have a question as when i put a breakpoint in both sub new it never hits when i first call dim s as string = GlobalConnections. strconVrExternal from another class. I get the data fine but i cannot see it initialize. Only time a got a breakpoint hit was when i deleted all the debug symbols and only when i called ? GlobalConnections. strconVrExternal from immediate window.
Is there any chance that i won't get back data from this, thus hitting the catch ?
Thanks.

[RESOLVED] WPF Calendar Remove Blank space

$
0
0
Code:

<Calendar  DisplayMode="Month"  Name="DTRECFROM"></Calendar>

Hope somebody can help..Hopefully an easy one.

I have a WPF calendar inside a control and I've noticed there is a lot of blank space either side of the dates.

Is there a way to remove the blank space?Name:  calendar.jpg
Views: 168
Size:  19.5 KB

Additionally, increase the side of the font on inner part of the calendar with the dates on


Hope you can help.

Kind regards
Attached Images
 

My crystal report not working after publish with screen shot

$
0
0
My crystal report not working after publish with screen shot

hi, I have VISUAL STUDIO 2010, c#, with mysql database, i installed crystal report for visual studio.


all are working in the debugging mode in vs 2010
flow list is.
1. enter an id number in the textbox
2. after pressing the generate button , value of the textbox will be converted as a parameter of the crystal report
3. It shows the information of that i.d from the database.

screen shot here

Attachment 125055


after publishing my project crystal report no longer working.

screen shot here

Attachment 125057

been looking for the answer for the past 10 days. please help


this is my code from the report.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Reporting;

namespace WebApplication11
{
public partial class report : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//this portion of data come from webform where i stored it in a session state.

desk.Text = Session["desk"].ToString();
Label2quan.Text = Session["qty"].ToString();
Label1issuedto.Text = Session["toname"].ToString();
Label2dept.Text = Session["todept"].ToString();
Label1issuedby.Text = Session["fromname"].ToString();
Label2date.Text = Session["date"].ToString();
Labelid.Text = Session["idform"].ToString();

//this portion is where i try to fill in the data to the crystal report

string cs = "data source=dlssvr; database = geography; user id=sa; password=service@password1";
using (SqlConnection con = new SqlConnection(cs))
{
ReportDocument rdoc = new ReportDocument();
SqlCommand cmd = new SqlCommand("formproce", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable ds = new DataTable();
da.Fill(ds);
rdoc.Load(Server.MapPath("CrystalReport1.rpt"));
rdoc.SetDataSource(ds);
rdoc.SetParameterValue("j parameter",Convert.ToInt32(Session["idform"]));
CrystalReportViewer1.ReportSource = rdoc;
CrystalReportViewer1.DataBind();
}
}
}
}

Attachment 125053



i also did tried to copy aspnet_client folder to the published directory

i need wcf to test for an absolute address.

$
0
0
197 Points

737 Posts
i need wcf to test for an absolute address.

a few seconds ago|LINK

Hi.

i am trying the following:

Web server, i run the address: https://localhost/VSAPI/vsapiinfo.svc and i get:

To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:

svcutil.exe https://testwebappsrv/VSAPI/VSAPI.svc?wsdl

However this is not what i want.

I want the web service to understand that i want to run the ip address of the server. so it should say, for example:

To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:

svcutil.exe https://192.168.0.1/VSAPI/VSAPI.svc?wsdl

How can i make it understand the ip address? Thanks.

MY web.config:
Code:

<?xml version="1.0"?>
<configuration>
 
  <system.serviceModel>
    <client>
      <endpoint address="http://192.168.102.30/WSVistaWebClient/TicketingService.asmx"
        binding="basicHttpBinding" bindingConfiguration="TicketingService"
        contract="ServiceReferenceTicketingService.TicketingService"
        name="TicketingService" />
      <endpoint address="http://192.168.102.30/WSVistaWebClient/DataService.asmx"
        binding="basicHttpBinding" bindingConfiguration="DataService"
        contract="ServiceReferenceDataService.DataService" name="DataService" />
      <endpoint address="http://192.168.102.30/WSVistaWebClient/LoyaltyService.asmx"
        binding="basicHttpBinding" bindingConfiguration="LoyaltyService"
        contract="ServiceReferenceLoyaltyService.LoyaltyService" name="LoyaltyService" />
  <!--  <endpoint name="" address="" binding="wsHttpBinding" bindingConfiguration="defaultBasicHttpBinding" contract="VSAPIService.IVSAPI"/>
      <endpoint name="" address="" binding="wsHttpBinding" bindingConfiguration="defaultBasicHttpBindingInfo" contract="VSAPIService.IVSAPIINFO"/> -->
    </client>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
 
    <services>
      <service behaviorConfiguration="MyServiceBehavior" name="VSAPIService.VSAPI">
        <endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="defaultBasicHttpBinding" contract="VSAPIService.IVSAPI"/>
     
      </service>
      <service behaviorConfiguration="MyServiceBehaviorInfo" name="VSAPIService.VSAPIINFO">
        <endpoint address="mex" binding="basicHttpBinding" bindingConfiguration="defaultBasicHttpBindingInfo" contract="VSAPIService.IVSAPIINFO"/>
     
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="defaultBasicHttpBinding" maxReceivedMessageSize="3000000"  sendTimeout="00:05:00"> <!-- transferMode="Streamed" if multi transfer issues with server-->
          <security mode="Transport">
            <message clientCredentialType="Certificate" />
          </security>
        </binding>
        <binding name="defaultBasicHttpBindingInfo" maxReceivedMessageSize="3000000" sendTimeout="00:05:00">
          <security mode="Transport">
            <transport clientCredentialType="Certificate"></transport>
          </security>
        </binding>
        <binding name="TicketingService" sendTimeout="00:05:00" />
        <binding name="DataService" sendTimeout="00:05:00" maxReceivedMessageSize="3000000" />
        <binding name="LoyaltyService" sendTimeout="00:05:00" />
      </basicHttpBinding>   
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
    <!--    <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="VSAPIService.MyUserNamePasswordValidator, VSAPIService"/>
          </serviceCredentials> -->
        </behavior>
        <behavior name="MyServiceBehaviorInfo">
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
      <!--  <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="VSAPIService.MyUserNamePasswordValidatorInfo, VSAPIService"/>
          </serviceCredentials> -->
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  <!--  <extensions>
      <behaviorExtensions>
        <add name="WcfMessageLogger"
              type="VSAPIService.WcfMessageLoggerExtension, VSAPIService.VSAPI" />
      </behaviorExtensions>
    </extensions> -->
  </system.serviceModel>
  <system.web>
    <compilation debug="true"/>
  </system.web>
</configuration>

Problem Deserializing the jsonString

$
0
0
I have a question that requires a bird's eye view of this topic, since I am a newbie on WCF. I retrieved data from the database and serialized it into a valid json string. I set the service-side object properties using the <DataContract()> and the <Datamember()> tag as required. However when I tried to deserialized the json string I always get the Error: The data contract type '...' cannot be deserialized because the required data members '...' were not found. The string I used to deserialize is: [Dim strm As New MemoryStream(Encoding.UTF8.GetBytes(json))
Dim ser As New _
DataContractJsonSeriaalizer(ldsp.[GetType]())
ldsp = DirectCast(ser.ReadObject(strm), List (Of lds))]

Ldsp is: Dim ldsp as New List (Of lds)), where lds is a proxy object I.e. Client-side object, whicj has a <Serializable()> tag on top of the corresponding property names or public variables, as required.

My questions are: 1. What causes this error?
2. Do I need to add values or initialize the service object before doing the deserialization or do I leave the object empty since all the data is in the jsonstring?
3. Please refer me to a good tutorial on how to deserialize the object properties, with the List (Of Object).
4. I suspect the problem has to do with the : Return list (Of lds) but I can't see how. Is this Return statement correct.

Please assist. I have tried the net with no luck and am desperate now. Thanks

Grouping and Row Details for DataGrid

$
0
0
Hi every 1

Please i'm new with WPF, i have DB with 2 tables (Customers_details,Customers_Activities) and i want my WPF (vb.net) app datagrid to do the following :

1- show the customers details with group the customers names.
2- second datagrid for the first datagrid as row details template to show the Customer activities.

is it possible to make something like this ??

Passing a filepath to a web service - Problem

$
0
0
I am trying to pass a string: c:\Books\image.jpg to a web service with no success. I tried to encode it as: <Code> returnString = HttpUtility.UriEncode(pathString)</Code>

The encoding works fine but I still get the Error 400 (Bad request). I get the same error if I pass a string with a dot such :(This is not good.) But if I remove the dot, the request goes through. What causes the error and how do we solve? The encoding does not seem to work. Thanks for helping.

WCF service in local IIS and run with Jquery.

$
0
0
Hi.
Is that so hard? Do i need cross domain stuff???
I am creating a simple WCF and i want to call it from local IIS. I cannot do it, whatever i try.
The service will work if i have it inside a web site but not stand alone.
Here is the data:
Code:

''Service:
Imports System.ServiceModel.Activation
Imports System.Web.Script.Serialization

' NOTE: You can use the "Rename" command on the context menu to change the class name "VSAPIAJAX" in code, svc and config file together.
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class VSAPIAJAX
    Implements IVSAPIAJAX

    Public Sub DoWork() Implements IVSAPIAJAX.DoWork
    End Sub

    Function test() As String Implements IVSAPIAJAX.test
        Return "g"
    End Function
End Class

Code:

interface:
Imports System.ServiceModel
Imports System.ServiceModel.Web
Imports System.Runtime.Serialization

' NOTE: You can use the "Rename" command on the context menu to change the interface name "IVSAPIAJAX" in both code and config file together.
<ServiceContract()>
Public Interface IVSAPIAJAX

    <OperationContract()>
    Sub DoWork()

    <WebInvoke(Method:="POST", ResponseFormat:=WebMessageFormat.Json)> _
    <OperationContract()> _
    Function test() As String


End Interface

Code:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="ServiceAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>     
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>             
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>     
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="VSAPIAJAX">
        <endpoint address="" behaviorConfiguration="ServiceAspNetAjaxBehavior"
          binding="webHttpBinding" contract="IVSAPIAJAX">
          <!--  <identity>
            <dns value="localhost" />
          </identity> -->
        </endpoint>       
      </service>       
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
 
</configuration>

Code:

//Javascript

<script src="Javascript/jquery-1.11.2.min.js" type="text/javascript"></script>
 <script type="text/javascript">
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "http://localhost:15328/VSAPIAJAX.svc/test",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response) {
                alert('d');
                try {
                    var oRetVal = response.d;
                    alert(d);
                }
                catch (ex) {
                    alert(ex);
                }
            },
            failure: function (msg) {
                alert(msg);
            }
        });
        alert('error');
    });
    </script>

Have tried local iis and local website asp server.Cannot get anything. Is this so hard to call a WCF service outside a web site?
Thanks

[RESOLVED] WCF service in local IIS and run with Jquery.

$
0
0
Hi.
Is that so hard? Do i need cross domain stuff???
I am creating a simple WCF and i want to call it from local IIS. I cannot do it, whatever i try.
The service will work if i have it inside a web site but not stand alone.
Here is the data:
Code:

''Service:
Imports System.ServiceModel.Activation
Imports System.Web.Script.Serialization

' NOTE: You can use the "Rename" command on the context menu to change the class name "VSAPIAJAX" in code, svc and config file together.
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class VSAPIAJAX
    Implements IVSAPIAJAX

    Public Sub DoWork() Implements IVSAPIAJAX.DoWork
    End Sub

    Function test() As String Implements IVSAPIAJAX.test
        Return "g"
    End Function
End Class

Code:

interface:
Imports System.ServiceModel
Imports System.ServiceModel.Web
Imports System.Runtime.Serialization

' NOTE: You can use the "Rename" command on the context menu to change the interface name "IVSAPIAJAX" in both code and config file together.
<ServiceContract()>
Public Interface IVSAPIAJAX

    <OperationContract()>
    Sub DoWork()

    <WebInvoke(Method:="POST", ResponseFormat:=WebMessageFormat.Json)> _
    <OperationContract()> _
    Function test() As String


End Interface

Code:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="ServiceAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>     
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>             
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>     
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="VSAPIAJAX">
        <endpoint address="" behaviorConfiguration="ServiceAspNetAjaxBehavior"
          binding="webHttpBinding" contract="IVSAPIAJAX">
          <!--  <identity>
            <dns value="localhost" />
          </identity> -->
        </endpoint>       
      </service>       
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
 
</configuration>

Code:

//Javascript

<script src="Javascript/jquery-1.11.2.min.js" type="text/javascript"></script>
 <script type="text/javascript">
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "http://localhost:15328/VSAPIAJAX.svc/test",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response) {
                alert('d');
                try {
                    var oRetVal = response.d;
                    alert(d);
                }
                catch (ex) {
                    alert(ex);
                }
            },
            failure: function (msg) {
                alert(msg);
            }
        });
        alert('error');
    });
    </script>

Have tried local iis and local website asp server.Cannot get anything. Is this so hard to call a WCF service outside a web site?
Thanks

User control label

$
0
0
Hi,
I am new to VB.NET and WPF. I have been working from an example i found and modifying it to suit my needs.
I have created a user control which i want to use as a button (i dont like the way buttons look for this project). My user control works as i would like but i would like to update the label text from the WPF. I will have many of these user controls on the same form. How would i set a different label for each user control i add?
I have tried finding the answer but i dont think i understand enough about WPF/XAML to get this working!


Thanks,
Alex

Transitioning to WPF from WinForms

$
0
0
I have been reading a book (Pro WPF in C# 2010) to start myself off with WPF. Traditionally I have been using WinForms to do my app design (with all kinds of custom gradient paints, timer animations, etc), but as this book suggests, WPF seems to be the next natural progression as I would like to start designing slicker animations and give my apps better dynamic and fluid functionality. That being said, I have a few questions about WPF:


1) How come "Components" do not exist for WPF like they do in the WinForms designer? For example, background worker and timers have to be hand-coded (or at least with my current level of familiarity) like so:

Code:

DispatcherTimer mytimer = new DispatcherTimer();
        mytimer.Tick += new EventHandler(DoSomething);
        mytimer.Interval = new TimeSpan(0,0,10);
        mytimer.Start();

It seems like a first world problem I guess, but I like being able to visually design with some of my elements.

2) The book mentions looking into using Microsoft Expression Blend to handle some of the XAML coding. My understanding of this software is that it is an advanced designer that lets you better create the XAML for animations and effects. I have seen some users even say using WPF is pointless unless you have access to that tool. For anyone using this technology do you agree with that assessment? Now, the problem is that I have VS2010, and I cannot locate the Expression Blend software anywhere. It looks like it no longer exists as a download for VS2010. The current downloads only show for VS2012+, so I may not be able to obtain that software :/

Any insight or clarification would be appreciated, thanks.

Need to create movable buttons. Ideas and pointers please.

$
0
0
I am finally moving into the 21st century and have taken the plunge into WPF, Xaml. I have read some tutorials and have a free 3 months subscription to PluralSight which I plan to use extensively.

I am rewriting a windows form program where I programably added buttons to a Panel and was able to drag them around with the mouse.

I have looked at WPF and the Canvas control seems to be the place to start but from what I have read this is "Noob" (Oh how I hate that term) mistake.

So any ideas or pointers to ideas how I might go about this.
I am really very new to this, so if you can keep it simple I would appreciate it.

How to align control in vertical mode in a horizontal stack panel

$
0
0
Hi,

I've used a stack panel to align two radio button in horizontal mode, but I want add a datagrid in the same stackpanel in vertical mode.

Code:

<GroupBox Grid.Column="2" Header="Approfondimento pronostici" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >
                        <StackPanel Orientation="Horizontal">
                            <RadioButton Content="Primo tempo" Margin="3,5,0,128" />
                            <RadioButton Content="Parziale/Finale" Margin="8,5,8,128" />
                            <DataGrid ColumnWidth="*" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Auto" AutoGenerateColumns="False"  Width="auto">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" Header="Squadra" MinWidth="100"/>
                                    <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" Header="1" MinWidth="40" CanUserResize="False" />
                                    <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" Header="X" MinWidth="40" CanUserResize="False" />
                                    <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" Header="2" MinWidth="40" CanUserResize="False" />
                                    <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" Header="un 1.5" MinWidth="40" CanUserResize="False" />
                                    <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" Header="ov 1.5" MinWidth="40" CanUserResize="False" />
                                </DataGrid.Columns>
                            </DataGrid>
                        </StackPanel>

I set the margin of control to let you know how it should be .. the radio button and the datagrid are positioned in a groupbox. How can I fix?

[RESOLVED] Is there a way to force inclusion of a data contract?

$
0
0
I am using VS2012 and .NET 4.5 on Windows 7.

I have a web service that has been working for quite some time. At issue is a specific data contract that is returned by only two Operation Contracts. For reasons of my own, I wanted to have them return a generic object that the GUI client could then cast into the appropriate type. Here's the data contract in question:

Code:

    [DataContract]
    public class MeasureSummary
    {
        [DataMember]
        public int PQRSMeasureID { get; set; }

        [DataMember]
        public int? MeasureNumber { get; set; }

        [DataMember]
        public int ScenarioCount { get; set; }

        [DataMember]
        public int TotalDiagCodeCount { get; set; }

        [DataMember]
        public int TotalProcCodeCount { get; set; }

        [DataMember]
        public int TotalNumerCodeCount { get; set; }

        [DataMember]
        public int TotalCodeCount { get; set; }
    }

    [OperationContract]
    [FaultContract(typeof(MeasureFault))]
    MeasureSummary GetMeasureSummary(int MeasureID);

    [OperationContract]
    [FaultContract(typeof(MeasureFault))]
    MeasureSummary GetAllMeasuresSummary();


All that worked fine. So I converted the first of the two operation contracts, and it worked fine. It returned the following datatype:

Code:

    [OperationContract]
    [FaultContract(typeof(MeasureFault))]
    GenericReturnType GetMeasureSummary(int MeasureID);

    [DataContract]
    public class GenericReturnType
    {
        [DataMember]
        public ErrorDetails Error { get; set; }

        [DataMember]
        public Object ReturnData { get; set; }
    }

In this return type, I store some very detailed information in ErrorDetails on where the service error occurred and what it was, above and beyond the standard Exception class. And ReturnData contains whatever data should be returned.

As I said, this worked just fine... it got the requested data and the client cast the ReturnData object into the desired MeasureSummary data. Bingo. Concept validated and functioning properly.

Then I converted the second as follows:

Code:

        [OperationContract]
        [FaultContract(typeof(MeasureFault))]
        GenericReturnType GetAllMeasuresSummary();

At this point, something very strange happened. The compiler started issuing errors when trying to compile the GUI client, saying that MeasureSummary wasn't a recognizable data type. After some thought, I built a dummy function as an operation contract that returned MeasureSummary, and then the client could see the data type again. I removed the dummy function from the interface, and got the error again. Added it back, and things worked like a charm.

Code:

        [OperationContract]
        [FaultContract(typeof(MeasureFault))]
        MeasureSummary GetMSTest();

So my conclusion is that the data contract wasn't built and released because no operation contract actually used the data type. And, since it isn't used, it doesn't even allow the client to know there is such a data type. Is there a way to force it to do so, anyway? For my purpose, I need the client to see the MeasureSummary datatype, regardless of whether or not it is specifically used by any operations.

Any suggestions would be appreciated.
Viewing all 277 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>