i am working on network application, and im sending this object from client to server..
at rcving i get an error.. this is my class of which object im sending
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace DrawingClient
{
[Serializable]
class myClass
{
public List<Point> points = new List<Point>();
}
}
and at rcving exactly where im de serializing the object.. im getting this exception..
Unable To Find Assembly drawing client, version=1.0.0.0, Culture=neutral PublicKeyToken=nulland i have all the assemblies at both server and at client end.. im testing it on my localhost.. mean both client and server are at localhost.. and same namespaces reffered in both applications.. im using tcpclient and tcplistener..
i made a dll in which i placed this class, and than referenced that dll in my Project at both ends and problem is solved..
actually when working with binary serialization assembly information also travels like my project name was rummykhan and my class name of which object i was serializing was book so the assembly information now include rummykhan.book and at client side assembly information is rummykhanclient.book so it was not deserializing.. when i made a dll and referenced it to both ends now assembly information is same and now its working.
PS
another part of information was also traveling along that was version information.. which we can control from the properties of the project.. and it must be same also..
Related
I'm looking for a way (may not be possible) to get a Revit file from the Autodesk
Desktop Connector to a Document class so I won't have to use the cloud API's.
The code below doesn't compile but does represented the genral idea, any thoughts ?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Autodesk.Connectivity.WebServices;
using Autodesk.Connectivity.WebServicesTools;
using Autodesk.Revit.DB;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
// Set up connection to the Autodesk Desktop Connector
WebServiceManager serviceManager = WebServiceManager.GetServiceManager();
string ticket = serviceManager.SecurityService.Authenticate();
// Get the list of files in the Autodesk Desktop Connector
File[] files = serviceManager.DocumentService.FindFiles(ticket, "*.rvt");
// Open the first Revit file in the list
Document doc = Autodesk.Revit.ApplicationServices.Application.OpenDocumentFile(files[0].path);
}
}
}
No, you cannot access the Revit Document class from such an external context. To access it, you need to be in a valid Revit API context:
Use of the Revit API Requires a Valid Context
Valid Revit API Context and External Events
Such a context is either provided by running Revit.exe on your Windows desktop and installing an add-in implementing the requisite Revit API event handlers, or by making use of the Autodesk Platform Services APS (formerly Forge) Design Automation API.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace IndentityDemo.Controllers
{
public class SecretController : Controller
{
//
// GET: /Secret/
public ContentResult Secret()
{
return Content("This is secret...");
}
}
}
I'm writing code in VS2013. I've created a controller named SecretController.
After build.. I've write url in browser .. "http://localhost:14516/Secret/Secret" but it give me the Error as bellow:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Secret/Secret
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0
My HomeController Working fine. But Controller can't be reached. Even when I attach a break point to the controller method it giving me a warning that 'The breakpoint will not currently be hit'
Please help me resolve this problem.
Try to add:
public SecretController() { }
before your Secret()
Finally got ODP.NET configured and the Oracle.ManagedDataAccess DLL referenced in the project.
I was testing with a TNS connection in the code behind in a WPF project (see below).
This question is probably elementary, but I can't find any good information on this, as all examples/jump-starts show embedding the connection string like this.
Is there a better (more common) way to store the connection string for ODP.NET to make it easier to maintain (i.e. it should be a configuration change that doesn't require completely rebuilding the code if it should change)? For example, similar to storing in app.config for SQL Server and IIS?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
namespace TEST
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private OracleConnection con;
public MainWindow()
{
InitializeComponent();
try
{
con = new OracleConnection("User Id=*****; Password=******; Data Source=******");
con.Open();
}
catch (OracleException oracleErr)
{
MessageBox.Show(oracleErr.Message);
}
finally
{
con.Close();
}
}
}
}
In case you used the tnsnames.ora from the Oracle Client for the unmanaged version then for the managed version you just have to copy the tnsnames to your project directory.
I am trying to create a web setup for my web site, and I want to use an installer class to do some custom stuff. I am using VS 2010, and the web site and installer is .NET 3.5.
I have added reference to the installer class project output in the Install section under Custom Actions:
I have also set /targetdir="[TARGETDIR]/" on the CustomActionData for this action.
The InstallScript project is a standard class library (dll).
There is a public class that inherits from Installer class. It overrides the Install method as I have seen been done in several online examples:
using System.Collections;
using System.Windows.Forms;
namespace InstallScript
{
public class MyWebInstaller : System.Configuration.Install.Installer
{
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
var targetDir = Context.Parameters["targetdir"];
if(targetDir==null) targetDir = "No TARGETDIR!";
MessageBox.Show("TARGETDIR:\t" + targetDir);
}
}
}
I would think there should be shown a message box here som time during the install, but it seems like it is never called. No error is shown either. The setup just runs through as if this code was never called.
Anyone have idea of what is wrong?
OK, I found out what was missing.
You need to specify the class with the class attribute RunInstaller(true) for the setup to pick up and actually run the code.
So the class needs to be declared like this:
[System.ComponentModel.RunInstaller(true)]
public class MyWebInstaller : System.Configuration.Install.Installer
{
...
Recently i created an application which could get the password of the user, whose username is provided as the parameter, i checked the code, its working fine, now i created a class library so that i can add this assemnbly in sql server 2008, below is the code of my class library.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
public class DnnUserCredentials
{
public static string GetUserPassword(string username)
{
MembershipUser objUser = Membership.GetUser(username);
return objUser.GetPassword();
}
}
i created the assembly in sql server 2008 like below
CREATE ASSEMBLY DNN_USER_CREDENTIALS FROM 'E:\NBM SITES\SqlProjectDll (DO NOT DELETE)\UserCredentials.dll' WITH PERMISSION_SET = SAFE
i got the command completed successfully message, then i created a function like below:
ALTER FUNCTION [dbo].[fn_UserCredentials](#UserName [nvarchar](max))
RETURNS [nvarchar](max) WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [DNN_USER_CREDENTIALS].[DnnUserCredentials].[GetUserPassword]
here too i got the command completed successfully message, now when i tried to call the function using
SELECT [dbo].[fn_UserCredentials]('host')
it throws me below error:
A .NET Framework error occurred during execution of user-defined routine or aggregate "fn_UserCredentials":
System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
System.Security.SecurityException:
at DnnUserCredentials.GetUserPassword(String username)
any solutions.
Not sure what can be the problem. First try to change the PERMISSION_SET to Unrestricted.
When this does not help try to debug the DLL from visual studio.
You need to set PERMISSION_SET = UNSAFE to get access to remote resources.
Also you might want to set TRUSTWORTHY flag to ON.
ALTER [<DBName>] SET TRUSTWORTHY ON
GO
CREATE ASSEMBLY [<assemblyName>]
--user with sysadmin rights for this DB may be required for deploing
AUTHORIZATION [<someSysadmin>]
FROM '[<pathToDll>]'
--compiled with unsafe to access EventLog for example
WITH PERMISSION_SET = UNSAFE
GO