1
Answer

inconsistent accessibility

inconsistent accessibility ;return type getuser is less accessible than method Service1. users -- how to rectify this error
 
Service1.cs
 
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace wcfdocsys
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
public class Service1 : IService1
{
SqlConnection con;
SqlCommand com;
SqlConnectionStringBuilder constr;
void connect()
{
constr = new SqlConnectionStringBuilder();
constr.DataSource = "HP-PC\\SQLEXPRESS";
constr.InitialCatalog = "DocSystem";
constr.Encrypt = true;
constr.TrustServerCertificate = true;
constr.ConnectTimeout = 30;
constr.AsynchronousProcessing = true;
constr.MultipleActiveResultSets = true;
constr.IntegratedSecurity = true;
con = new SqlConnection(constr.ToString());
com = con.CreateCommand();
}
public getuser users() //this is showing error
{
getuser getuser = new getuser();
try
{
com.CommandText = "Select * from tblUser_stg";
com.CommandType = CommandType.Text;
con.Open();
SqlDataReader rd = com.ExecuteReader();
while (rd.Read())
{
getuser.slno = Convert.ToInt32(rd[0]);
getuser.UserID = rd[1].ToString();
getuser.UserName = rd[2].ToString();
getuser.Password = rd[3].ToString();
getuser.ForceChangePassword = Convert.ToBoolean(rd[4]);
getuser.RoleID = Convert.ToInt32(rd[5]);
getuser.isActive = Convert.ToBoolean(rd[6]);
}
return getuser;
}
catch (Exception)
{
throw;
}
finally
{
if (con != null)
{
con.Close();
}
}
}
}
}
 
IService1.cs
[OperationContract]
getuser users(); //it also shows same error

Answers (1)

0
Photo of Priya Linge
NA 5k 708.3k 13y

Attachment uploadimages.rar

Hi,

You can upload images as follow,

On Button_click.

  private void button1_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "JPEG files|*.jpg";
            //openFileDialog.Filter = "Images (*.jpg, *.png, *.bmp)|*.jpg;*.png;*.bmp";
            if (openFileDialog.ShowDialog() == true)
            {
                Stream stream = (Stream)openFileDialog.File.OpenRead();
                byte[] bytes = new byte[stream.Length];
                stream.Read(bytes, 0, (int)stream.Length);
                bi = new BitmapImage();
                bi.SetSource(stream);
                Myimage.Source = bi;
                string fileName = openFileDialog.File.Name;

                ServiceReference1.ImageFile imagefile = new ServiceReference1.ImageFile();
                imagefile.ImageName = fileName;
                imagefile.Imagestream = bytes;

//Serive call for saving your images in server folder.

                ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
                service.UploadCompleted += new EventHandler<ServiceReference1.UploadCompletedEventArgs>(service_UploadCompleted);
                service.UploadAsync(imagefile);

At service side we have following code to save images in server folder.


public bool Upload(ImageFile image)
        {
            FileStream fileStream = null;
            BinaryWriter writer = null;
            string filePath;
            try
            {
                filePath = HttpContext.Current.Server.MapPath(".") + ConfigurationManager.AppSettings["PictureUploadDirectory"] + image.ImageName;
                if (image.ImageName != string.Empty)
                {
                    fileStream = File.Open(filePath, FileMode.Create);
                    writer = new BinaryWriter(fileStream);
                    writer.Write(image.ImageName);
                }
                return true;
            }

         catch (Exception)
            {
                return false;
            }
            finally
            {
                if (fileStream != null)  
                    fileStream.Close();
                if (writer != null)    
                    writer.Close();
            }
        }
         

You can check images which keeps in pictures folder in server,

D:\\priya\\dotnet\\silverlight applications\\Uploadimages\\Uploadimages.Web/Pictures/pis.jpg.

Please see attached file .

Accepted
0
Photo of mahesh
NA 116 67.4k 13y
Thank you so much..
0
Photo of Jiteendra Sampathirao
NA 6.9k 1.5m 13y

Hi mahesh go through this thread

hope it will help you......