If you are trying to install a .NET 2.0 assembly to a client, you will notice that although the framework is installed, gacutil is missing.
So, you can copy gacutil from here, and you can send it with your assembly to client:
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\
Tuesday, July 14, 2009
Adding new assembly to SharePoint
There are two ways to use your assembly in SharePoint:
1. Copy it to bin folder.
2. Move assembly into GAC.
If you put it in your bin folder, you will have partial trust, and your component cannot access to system resources such as registry. If you want to have full access then sign the component and add it to GAC.
After you add it to GAC, you have to add 2 entries to web.config:
1. To safe controls:
2. To compilation:
1. Copy it to bin folder.
2. Move assembly into GAC.
If you put it in your bin folder, you will have partial trust, and your component cannot access to system resources such as registry. If you want to have full access then sign the component and add it to GAC.
After you add it to GAC, you have to add 2 entries to web.config:
1. To safe controls:
<safecontrol assembly="Baris.Security.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=20408sdf323sf" safe="True" typename="*" namespace="Baris.Security.Common">
2. To compilation:
<add assembly="Baris.Security.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=20408sdf323sf">
Monday, July 13, 2009
Re-sign assemblies if you don't have the source code
So, you have a third party assembly, and want to put it into GAC. (Or maybe into SharePoint, you have just figured that the "bin" folder does not allow your assemblies full trust to resources like registry).
Here are the steps:
Here are the steps:
1> ildasm /all /out=MyAsm.il MyAsm.dll
2> ilasm /dll /key=Companykey.snk MyAsm.il
2> ilasm /dll /key=Companykey.snk MyAsm.il
Remote Desktop Port : 3389
The default port is> 3389
Registry location> HKEY_LOCAL_MACHINE\ System\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp
Connecting to machine with different port> computername:port
Registry location> HKEY_LOCAL_MACHINE\ System\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp
Connecting to machine with different port> computername:port
Thursday, July 09, 2009
IIS Error: Failed to access IIS metabase, "The process account used to run ASP.NET must have read access to the IIS metabase"
If you experience this error, probably you have installed IIS after .NET installation. So, what you need to do is to stop IIS and re-install ASP.NET for both 1.1 and 2.0.
Run the following command set (better create an x.cmd file and run that), and don't forget to change machinename to your computer's name:
And that is it :)
Run the following command set (better create an x.cmd file and run that), and don't forget to change machinename to your computer's name:
iisreset -stop
cd\
cd %windir%Microsoft.NET\Framework\v2.0.50727
aspnet_regiis -ua
aspnet_regiis -i
aspnet_regiis -ga machinename\ASPNET
cd\
cd %windir%Microsoft.NET\Framework\v1.1.4322
aspnet_regiis -i
iisreset -start
cd\
cd %windir%Microsoft.NET\Framework\v2.0.50727
aspnet_regiis -ua
aspnet_regiis -i
aspnet_regiis -ga machinename\ASPNET
cd\
cd %windir%Microsoft.NET\Framework\v1.1.4322
aspnet_regiis -i
iisreset -start
And that is it :)
Thursday, March 22, 2007
Regex: Using named groups in .NET Regular Expressions
When you match a group in a regular expression, you can reference them in the replace expression with the syntax "$1, $2". But, the better way is to give every group a name.
in search -> (? ....pattern...)
in replace -> ${name}
\k --> back reference to a named match
Example:
I hope everything is clear in the example :)
in search -> (?
in replace -> ${name}
\k --> back reference to a named match
Example:
SearchPattern = (?<tag>bold)>(?<text>[\s\S]+?)</\k<tag>>
ChangePattern = <${tag}><font color=red>${text}</font></${tag}>
ChangePattern = <${tag}><font color=red>${text}</font></${tag}>
Text:
<bold>this text will be red</bold>
Result:
<bold><font color=red>this text will be red</font></bold>
<bold>this text will be red</bold>
Result:
<bold><font color=red>this text will be red</font></bold>
I hope everything is clear in the example :)
Wednesday, March 21, 2007
.NET: Combine array items into a string (deliminated with comma)
So, here is the quick way to achieve it:
ArrayList arr = new ArrayList();
arr.Add("test1");
arr.Add("test2");
arr.Add("test3");
//be sure all elements are string
string str = String.Join(",", (string[]) arr.ToArray(Type.GetType("System.String")));
MessageBox.Show(str); // test1,test2,test3
ArrayList arr = new ArrayList();
arr.Add("test1");
arr.Add("test2");
arr.Add("test3");
//be sure all elements are string
string str = String.Join(",", (string[]) arr.ToArray(Type.GetType("System.String")));
MessageBox.Show(str); // test1,test2,test3
SQL: Split function that parses comma delimated string
This is a function that I use frequently (also some of my friends). It is a function in Sql server, that parses a comma-deliminated string and returns a table. By returning a table, you can use this in joins. So, here is the function:
create function fn_Split(
@String nvarchar (4000),
@Delimiter nvarchar (10)
)
returns @ValueTable table ([Value] nvarchar(4000))
begin
declare @NextString nvarchar(4000)
declare @Pos int
declare @NextPos int
declare @CommaCheck nvarchar(1)
--Initialize
set @NextString = ''
set @CommaCheck = right(@String,1)
--Check for trailing Comma, if not exists, INSERT
if (@CommaCheck <> @Delimiter )
set @String = @String + @Delimiter
--Get position of first Comma
set @Pos = charindex(@Delimiter,@String)
set @NextPos = 1
--Loop while there is still a comma in the String of levels
while (@pos <> 0)
begin
set @NextString = substring(@String,1,@Pos - 1)
insert into @ValueTable ( [Value]) Values (@NextString)
set @String = substring(@String,@pos +1,len(@String))
set @NextPos = @Pos
set @pos = charindex(@Delimiter,@String)
end
return
end
go
How do we use it? Like that:
SELECT * FROM ServicesTable inner join dbo.fn_Split(@ServiceFilter, ',') tbl on tbl.[Value] = ServicesTable.Service)
* Here, the @ServiceFilter is something like "abc,xyz,123".
create function fn_Split(
@String nvarchar (4000),
@Delimiter nvarchar (10)
)
returns @ValueTable table ([Value] nvarchar(4000))
begin
declare @NextString nvarchar(4000)
declare @Pos int
declare @NextPos int
declare @CommaCheck nvarchar(1)
--Initialize
set @NextString = ''
set @CommaCheck = right(@String,1)
--Check for trailing Comma, if not exists, INSERT
if (@CommaCheck <> @Delimiter )
set @String = @String + @Delimiter
--Get position of first Comma
set @Pos = charindex(@Delimiter,@String)
set @NextPos = 1
--Loop while there is still a comma in the String of levels
while (@pos <> 0)
begin
set @NextString = substring(@String,1,@Pos - 1)
insert into @ValueTable ( [Value]) Values (@NextString)
set @String = substring(@String,@pos +1,len(@String))
set @NextPos = @Pos
set @pos = charindex(@Delimiter,@String)
end
return
end
go
How do we use it? Like that:
SELECT * FROM ServicesTable inner join dbo.fn_Split(@ServiceFilter, ',') tbl on tbl.[Value] = ServicesTable.Service)
* Here, the @ServiceFilter is something like "abc,xyz,123".
Friday, January 20, 2006
HowTo: Install new assembly into GAC with key
I made a search on web, and this subject is not clearly defined in anywhere. Here is my blog on it:
1) prepare a key once:> sn.exe -k companyKeyPair.snk
2) on each client:> sn.exe -i companyKeyPair.snk
3) add your key to assemby (CompanyKey)
AssemblyInfo.cs: AssemblyKeyName("CompanyKey")]
4) add your assembly into GAC:> gacutil /i MyObject.dll
5) Now, to make your life easier, know that Visual Studio.NET doesn't check the GAC when you add references to projects. It checks a registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders
If you add a key below that key with a default value (string) of the path of where your assemblies are located, the next run of VS.NET will check that folder and your assemblies will show up in the dialog of the .NET references.
1) prepare a key once:> sn.exe -k companyKeyPair.snk
2) on each client:> sn.exe -i companyKeyPair.snk
3) add your key to assemby (CompanyKey)
AssemblyInfo.cs: AssemblyKeyName("CompanyKey")]
4) add your assembly into GAC:> gacutil /i MyObject.dll
5) Now, to make your life easier, know that Visual Studio.NET doesn't check the GAC when you add references to projects. It checks a registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders
If you add a key below that key with a default value (string) of the path of where your assemblies are located, the next run of VS.NET will check that folder and your assemblies will show up in the dialog of the .NET references.
Thursday, January 19, 2006
My first blog
This is my first blog. I want to write technical .NET subjects daily, and some photos about my life. I am developing mostly in asp.net and trying to create nice server control. I hope I can share my knowladge with most of the people.
Today I create a nice datagrid control with hover on the rows. And I found a very nice trick to postback the selected row to server.
I will try to post the code soon.
Today I create a nice datagrid control with hover on the rows. And I found a very nice trick to postback the selected row to server.
I will try to post the code soon.
Subscribe to:
Posts (Atom)