|
All Happy Now!
We have an existing ASP.NET app (C# backend) that was originally written with weakly named backend objects, distributed to our customer's via traditional "XCOPY" (actually InstallShield, but just dropping files in the right location), so that all of the necessary DLL's are installed in the /bin directory of the default website. This works fine for just one app.
Now, we are in the process of adding additional applications to our existing one, and in order to do that, we are strong-naming our components and trying to install them to the GAC, so that they can be globally referenced. I have successfully strong-named all of our components, and can put them into the GAC without issue as well. However, when I remove the /bin directory after having placed the components in the GAC, I get "Object Not Found" errors when trying to run the app.
Is there something I need to change in the way my .DLLs reference each other, so that the app will search the GAC when loading?
This is somewhat urgent as we are midway through the design process and starting to reconfigure our existing code. If our distribution plans are misinformed, we need to know now so we can lay a better path.
Thanks for any help we can get!
|
|
|
|
|
This doesn't directly answer your question, but I wouldn't put assemblies into the GAC during development. This can be a real pain, because you have to specifically tell gacutil to uninstall the assembly first or force it to re-install over an existing install:
gacutil /f /i myassembly.dll
But this fails if you've installed the assembly with MSI, because it can only be uninstalled using MSI!
It's easier to add things to the GAC as part of installation and test the installation separately--NOT on the development platform. Use VirtualPC or something to ensure a clean, reproducable install environment.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Thanks, but distribution is what I'm trying to test at this point. We've already got the development environment running and compiling together with the strong-named assemblies. It's when I try to test how the application works with its core dlls in the GAC that I'm running into trouble.
One thing that I'm doing that may not be right is I'm using the Windows Explorer add-on to install the dlls to the GAC, not GACUtil. I wouldn't think that's the problem, because I get the same failures when I use the InstallShield distribution. So I figured it has something to do with how we reference the DLLs.
Thanks for looking and responding!
Kerry
|
|
|
|
|
|
I imagine this topic has been resolved many times, but I beg for your help.
I am trying to run the most simple Remoting example and simply it refuses to work in my computer.
Why? I don't know but this is really bother me.
You can see one example that also can not run in my computer following the link:
http://www.codeproject.com/csharp/RemotingChatSample.asp
Could you please tell me what is my problem.
Regards
Ewing
|
|
|
|
|
Hi;
If you are running this accross a network, have you check to make sure that no firewall are blooking the connection? if you are running accross a network try running it on the same machine, localhost and see if you have the same problem.
-Fernando
|
|
|
|
|
i am connecting with sqlserver database ,then i need to acces that user which is in my textbox ,but no user comming from it.
code is as follows:
sqlConnString="server= your server; database= ;user id=;password=;";
sqlConn = new SqlConnection(sqlConnString);
sqlConn.Open();
sqlCmd = new SqlCommand(“select username,password from table where username=@textbox1.text”);
sqlDataAdapter da = new SqlDataAdapter();
da= cmd.executeReader()
If da.read()
{
responser.redirect(“loginsuccess.aspx”)
}
else
{
response.write(“invalid login.aspx”)
}
+++++++++++++++++++++++++++
error is this
System.Data.SqlClient.SqlException: Must declare the variable '@TextBox1'. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at ASP.UserInfo_aspx.Page_Load()
|
|
|
|
|
cishi_us wrote:
Must declare the variable '@TextBox1'
Read up on how to use the SqlParameter object. Also, just use "@TextBox1", not "@TextBox1.Text".
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
I have finally solved my dropdownlist databinding issue....Next prolem. I now have a selected value. That value correpsopnds to a row of data. How do I access this data?
Here is my code.
Thanks in advance
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
DropDownList DropList = new DropDownList();<br />
<br />
DropList.ID = "AirportList";<br />
DropList.AutoPostBack = true;<br />
<br />
DropList.SelectedIndexChanged += <br />
new EventHandler(this.Selection_Change);<br />
<br />
oleDbDataAdapter1.Fill(dsn_AirportList1,"tblAirport");<br />
Session["DSN_AirportList"] = dsn_AirportList1;<br />
DropList.DataSource = dsn_AirportList1;<br />
DropList.DataTextField = "AirportName";<br />
DropList.DataBind();<br />
if(!IsPostBack)<br />
{ <br />
DropList.SelectedIndex = 0;<br />
}<br />
PlaceHolder1.Controls.Add(DropList);<br />
}<br />
#region Web Form Designer generated code<br />
override protected void OnInit(EventArgs e)<br />
{<br />
InitializeComponent();<br />
base.OnInit(e);<br />
}<br />
<br />
private void InitializeComponent()<br />
{ <br />
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();<br />
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();<br />
this.oleDbConnection2 = new System.Data.OleDb.OleDbConnection();<br />
this.dsn_AirportList1 = new DSN_AirportList();<br />
((System.ComponentModel.ISupportInitialize)(this.dsn_AirportList1)).BeginInit();<br />
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;<br />
this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {<br />
new System.Data.Common.DataTableMapping("Table", "tblAirport", new System.Data.Common.DataColumnMapping[] {<br />
new System.Data.Common.DataColumnMapping("AirportCode", "AirportCode"),<br />
new System.Data.Common.DataColumnMapping("AirportID", "AirportID"),<br />
new System.Data.Common.DataColumnMapping("AirportName", "AirportName"),<br />
new System.Data.Common.DataColumnMapping("City", "City"),<br />
new System.Data.Common.DataColumnMapping("Latitude", "Latitude"),<br />
new System.Data.Common.DataColumnMapping("Longitude", "Longitude"),<br />
new System.Data.Common.DataColumnMapping("State", "State")})});<br />
this.oleDbSelectCommand1.CommandText = "SELECT AirportCode, AirportID, AirportName, City, Latitude, Longitude, State FROM" +<br />
" tblAirport";<br />
this.oleDbSelectCommand1.Connection = this.oleDbConnection2;<br />
this.oleDbConnection2.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source=""D:\MGDevelopment\DropDownList2\DB\simdac_be.mdb"";Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1";<br />
this.dsn_AirportList1.DataSetName = "DSN_AirportList";<br />
this.dsn_AirportList1.Locale = new System.Globalization.CultureInfo("en-US");<br />
this.Load += new System.EventHandler(this.Page_Load);<br />
((System.ComponentModel.ISupportInitialize)(this.dsn_AirportList1)).EndInit();<br />
<br />
}<br />
#endregion<br />
<br />
void Selection_Change(Object sender, EventArgs e)<br />
{<br />
DropDownList DropList = <br />
(DropDownList)PlaceHolder1.FindControl("AirportList"); <br />
<br />
string xxx=DropList.SelectedItem.Value;<br />
int yy=DropList.Items.Count;<br />
}<br />
|
|
|
|
|
I figured it out......Too easy!
|
|
|
|
|
How you you list the branches of say, System.Windows.Forms ???
(I want to make code-completion in a .cs text editor)
-ProtoArmor
|
|
|
|
|
You can always look in System.Reflection for hints. You should also realize that assemblies and namespaces are not tied together. There might be more stuff in a given namspace that are in assemblies that aren't loaded.
|
|
|
|
|
From my AUT project, here's how I get the classes in an assembly for a particular namespace:
private ClassCollection GetClassCollection()
{
ClassCollection classCollection=new ClassCollection();
Type[] types=assembly.GetTypes();
foreach (Type type in types)
{
if (type.IsClass)
{
MethodInfo[] methods=type.GetMethods(Options.BindingFlags);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.DeclaringType.Namespace==namespaceName)
{
string className=StringHelpers.RightOfRightmostOf(methodInfo.DeclaringType.FullName, '.');
Type t=methodInfo.DeclaringType;
classCollection.Add(className, new ClassItem(assembly, namespaceName, className, type));
}
}
}
}
return classCollection;
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Hello all,
I am writing a client for a remote windows service using C#.
I first instantiate the remote object ...
Type t = Type.GetTypeFromProgID(progId, serverName);
APPLib.IApp obj = (APPLib.IApp)Activator.CreateInstance(type);
Then I use the method and it works great ..
obj.SomeMethod();
But if I unplug the network cable between the object creation and its use, I get a 0x800706BF COMException (The remote procedure call failed.) which is expected. The problem I have is after I reconnect the network cable and then try to recover by calling the Type.GetTypeFromProgID() and Activator.CreateInstance(type) methods, I repeatedly get "The remote procedure call failed." COM Exceptions in the Activator.CreateInstance() call. I can even start another instance of my client that connects to the remote server just fine while this instance is still throwing execptions.
Any suggestions on how to recover gracefully?
Thank you,
Bob
|
|
|
|
|
use try/catch
|
|
|
|
|
Thank you for the suggestion and I apologize for not being clearer. I do use try/catch blocks. I am attempting to implement some retry logic to handle the occasional network glitch. The CreateObject() method in the code below wraps the Type.GetTypeFromProgID() and Activator.CreateInstance() calls. The CreateObject() method is also the method I call to intially create the remote object (crudq in this code).
What I do to create this problem is set a breakpoint on the crudq.DatabaseQuery call. When the breakpoint is reached (and the remote object crudq is successfully created), I unplug the network cable and hit F10 to execute the call. The crudq.DatabaseQuery() throws a RPC_S_CALL_FAILED COMException. I then plug the network cable back in then F10 through the code. Every call to CreateObject() throws a RPC_S_CALL_FAILED COMException when it calls Activator.CreateInstance().
Below is the code:
<br />
public void DatabaseQuery(string databaseName, int instance, Object input, Object filter, ref Object output, ref int result)<br />
{<br />
bool retry = true;<br />
int count = 0;<br />
int r = 0;<br />
Object o;<br />
do<br />
{<br />
try<br />
{<br />
crudq.DatabaseQuery(databaseName, instance, timeout, input, filter, out o, out r);<br />
retry = false;<br />
result = r;<br />
output = o;<br />
}<br />
catch(COMException c)<br />
{<br />
if (count < retryAttempts && (c.ErrorCode == RPC_S_CALL_FAILED || c.ErrorCode == RPC_S_SERVER_UNAVAILABLE))<br />
{<br />
x.Info("DatabaseQuery: Retry count: " + count.ToString() + ", Exception: " + c.Message);<br />
Thread.Sleep(delayBetweenRetry);<br />
<br />
Object obj;<br />
try<br />
{<br />
CreateObject(progID, server, out obj);<br />
crudq = (AMSLib.ICRUDQ)obj;<br />
}<br />
catch<br />
{<br />
}<br />
++count;<br />
}<br />
else<br />
{<br />
x.Error("DatabaseQuery: Exception caught: " + c.Message, c);<br />
throw;<br />
}<br />
}<br />
catch(Exception e)<br />
{<br />
x.Error("DatabaseQuery: Exception caught: " + e.Message, e);<br />
throw;<br />
}<br />
}<br />
while(retry);<br />
}<br />
Thank you,
Bob
|
|
|
|
|
Hi
does anyone know where i can get a class to read ID3v1 and v2 tags in mp3-files?
And how can i read the information in wma files?
Hope you can help me
Thanks
|
|
|
|
|
Hmmm
I found a class for MP3 Ids, both V1 and V2.
I havent been able to take a look at them closely but in the following URL you can get the code and a working Demo.
URL:
http://www.csharphelp.com/archives/archive226.html[^]
About WMA, i dont know.
Greetings!
|
|
|
|
|
I'm trying to iterate through a Dictionary and remove some of the elements according to some criterion. I get an InvalidOperationException that says: "Collection was modified; enumeration operation may not execute."
IDictionary<IPAddress, DateTime> peers = new Dictionary<IPAddress, DateTime>();
foreach (KeyValuePair<IPAddress, DateTime> peer in peers) {
if (peer.Value < DateTime.Now) {
peers.Remove(peer.Key);
}
}
The condition given is not the actual condition (as it would remove all elements from the collection).
|
|
|
|
|
Foreach should not be used to change the contents of a collection. Use a for-loop instead.
www.troschuetz.de
|
|
|
|
|
But it isn't possible to go through a Dictionary with a for-loop. The only iteration tool available is the IEnumerator and that's what the foreach contruct uses!
|
|
|
|
|
Considering this restriction, I think the simpelst way to avoid the error would be to collect the keys of all elements that should be removed and then remove them after finishing the enumeration.
www.troschuetz.de
|
|
|
|
|
That's what I did, was just wondering if there was a better way to do it.
|
|
|
|
|
No, you are NOT.
You are looping over the Dictionary and removing entries at the same time.
Shove them into an ArrayList and remove them AFTER completion of the foreach-loop.
Cheers
Sid
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Perhaps I wasn't clear enough. I've got a working version that does as you described. I thought the solution was ugly and wondered if there was a better one.
|
|
|
|
|