Hi,
This My Properties Class:public class Uin{public Byte[] Image{set;get;}
This is My WcfService:
[OperationContract]
public List<Uin> UnivList(string UnivId)
{
var UList = new List<Uin>();
SqlConnection con = new SqlConnection("server=system1;Database=FirstGuardian;User Id=sa");
string query = "select UnivLogo from fg0uv000 where UnivID="+UnivId;
var cmd = new SqlCommand();
con.Open();
using (var dr = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
{
while (dr.Read())
{
var emp = new Uin();
if (!dr.IsDBNull(0))
{
byte[] blob = new byte[(dr.GetBytes(0, 0, null, 0, int.MaxValue))];
dr.GetBytes(0, 0, blob, 0, blob.Length);
using (MemoryStream ms = new MemoryStream())
{
ms.Write(blob, 78, blob.Length - 78);
Bitmap bm = (Bitmap)Image.FromStream(ms);
using (MemoryStream msJpg = new MemoryStream())
{
bm.Save(msJpg, ImageFormat.Jpeg);
emp.Image = msJpg.GetBuffer();
}
}
}
UList.Add(emp);
}
}
return UList;
}
And I Created ImageConverter Class and The Image Control in XAML Is Look Like:
xmlns:conv="clr-namespace:dynamicloading"
<UserControl.Resources>
<conv:ImageConverter x:Key="ImageConverter1" />
</UserControl.Resources>
<Image Height="150" HorizontalAlignment="Left" Margin="21,91,0,0" Name="Imglogo" Stretch="Fill" VerticalAlignment="Top" Width="200" Source="{Binding Path=Image, Converter={StaticResource ImageConverter1}}" />
And My Code Main.XAML.cs is Look Like:
Service1Client client = new Service1Client();
public MainPage()
{
InitializeComponent();
client.UnivListCompleted += new EventHandler<UnivListCompletedEventArgs>(client_UnivListCompleted);
client.UnivListAsync(Univid);
}
void client_UnivListCompleted(object sender, UnivListCompletedEventArgs e)
{
Imglogo.DataContext = e.Result;
}
The Above is The My CompletedCode.
But I Got Error Like:
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <servicedebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs
Please Give Me Advice to correct Me
thanks
vijay